created waiting llist
it contains only function for push
This commit is contained in:
parent
cdcc9e53b4
commit
278e880e62
@ -44,7 +44,14 @@ typedef struct node
|
||||
struct node *next;
|
||||
} node_t; //SINGLE LINKED LIST
|
||||
|
||||
typedef struct waiting_node
|
||||
{
|
||||
pthread_t thread;
|
||||
struct waiting_node *next;
|
||||
} waiting_node_t; //SINGLE LINKED LIST
|
||||
|
||||
node_t *head = NULL;
|
||||
waiting_node_t *waiting_head = NULL;
|
||||
|
||||
void push_to_list(int connection, pthread_t thread)
|
||||
{
|
||||
@ -67,6 +74,26 @@ void push_to_list(int connection, pthread_t thread)
|
||||
}
|
||||
}
|
||||
|
||||
void waiting_push_to_list(pthread_t thread)
|
||||
{
|
||||
//CREATE NODE
|
||||
waiting_node_t *new_node = malloc(sizeof(waiting_node_t));
|
||||
waiting_node_t *buffer = waiting_head;
|
||||
|
||||
new_node -> thread = thread;
|
||||
new_node -> next = NULL;
|
||||
|
||||
if (waiting_head == NULL) //INIT LIST
|
||||
{
|
||||
waiting_head = new_node;
|
||||
} else
|
||||
{
|
||||
while (buffer -> next != NULL) buffer = buffer -> next; //GET TO THE END OF LIST
|
||||
|
||||
buffer -> next = new_node; //LINK
|
||||
}
|
||||
}
|
||||
|
||||
void remove_node(node_t *node)
|
||||
{
|
||||
if (node == NULL) return; //NULL NODE
|
||||
|
Loading…
x
Reference in New Issue
Block a user