OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
task_thread_api.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 #include "task_thread_api.h"
9 #ifdef __cplusplus
10 }
11 #endif
12 
14 {
15  if (!head) {
16  return;
17  }
18 
19  head->next = head;
20  head->prev = head;
21 
22  return;
23 }
24 
26 {
27  return (head->next == head) ? TRUE : FALSE;
28 }
29 
31 {
32  return (head == node) ? TRUE : FALSE;
33 }
34 
35 boolean thread_node_on_thread(const task_thread *node)
36 {
37  return (node->next) ? TRUE : FALSE;
38 }
39 
41 {
42  if (head->next == head) {
43  return NULL;
44  }
45 
46  return head->next;
47 }
48 
50 {
51  node->next = head->next;
52  node->prev = head;
53  head->next = node;
54  node->next->prev = node;
55 
56  return;
57 }
58 
60 {
61  thread_circular_add_top(head->prev, node);
62 }
63 
65 {
66  return node->next;
67 }
68 
70 {
71  if (!node) {
72  return (head->next == head) ? NULL : head->next;
73  }
74 
75  return (node->next == head) ? NULL : node->next;
76 }
77 
79 {
80  if (!node->next) {
81  return;
82  }
83 
84  node->next->prev = node->prev;
85  node->prev->next = node->next;
86 
87  node->next = NULL;
88  node->prev = NULL;
89 }
90 
92 {
93  task_thread *current = NULL;
94 
95  if (head->next == head) {
96  return NULL;
97  }
98 
99  current = head->next;
100  thread_remove(current);
101 
102  return current;
103 }
104 
task_thread * thread_next_node(task_thread *node)
#define TRUE
Definition: mcast_common.h:15
boolean thread_circular_thread_empty(task_thread *head)
task_thread * thread_circular_top(task_thread *head)
task_thread * thread_circular_dequeue_top(task_thread *head)
struct thread_ * next
#define FALSE
Definition: mcast_common.h:14
task_thread * thread_circular_thread_next(task_thread *head, task_thread *node)
boolean thread_node_on_thread(const task_thread *node)
void thread_circular_add_bottom(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)
struct thread_ * prev
void thread_remove(task_thread *node)
boolean thread_circular_thread_head(task_thread *head, task_thread *node)