OpenSDN source code
task_thread_api.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 #include "task_thread_api.h"
10 #ifdef __cplusplus
11 }
12 #endif
13 
15 {
16  if (!head) {
17  return;
18  }
19 
20  head->next = head;
21  head->prev = head;
22 
23  return;
24 }
25 
27 {
28  return (head->next == head) ? TRUE : FALSE;
29 }
30 
32 {
33  return (head == node) ? TRUE : FALSE;
34 }
35 
36 boolean thread_node_on_thread(const task_thread *node)
37 {
38  return (node->next) ? TRUE : FALSE;
39 }
40 
42 {
43  if (head->next == head) {
44  return NULL;
45  }
46 
47  return head->next;
48 }
49 
51 {
52  node->next = head->next;
53  node->prev = head;
54  head->next = node;
55  node->next->prev = node;
56 
57  return;
58 }
59 
61 {
62  thread_circular_add_top(head->prev, node);
63 }
64 
66 {
67  return node->next;
68 }
69 
71 {
72  if (!node) {
73  return (head->next == head) ? NULL : head->next;
74  }
75 
76  return (node->next == head) ? NULL : node->next;
77 }
78 
80 {
81  if (!node->next) {
82  return;
83  }
84 
85  node->next->prev = node->prev;
86  node->prev->next = node->next;
87 
88  node->next = NULL;
89  node->prev = NULL;
90 }
91 
93 {
94  task_thread *current = NULL;
95 
96  if (head->next == head) {
97  return NULL;
98  }
99 
100  current = head->next;
101  thread_remove(current);
102 
103  return current;
104 }
105 
#define TRUE
Definition: mcast_common.h:16
#define FALSE
Definition: mcast_common.h:15
struct thread_ * next
struct thread_ * prev
void thread_circular_add_bottom(task_thread *head, task_thread *node)
task_thread * thread_circular_thread_next(task_thread *head, task_thread *node)
task_thread * thread_next_node(task_thread *node)
void thread_remove(task_thread *node)
boolean thread_circular_thread_empty(task_thread *head)
task_thread * thread_circular_top(task_thread *head)
boolean thread_circular_thread_head(task_thread *head, task_thread *node)
void thread_new_circular_thread(task_thread *head)
void thread_circular_add_top(task_thread *head, task_thread *node)
boolean thread_node_on_thread(const task_thread *node)
task_thread * thread_circular_dequeue_top(task_thread *head)