MCPcopy Create free account
hub / github.com/acl-dev/acl / queue_free

Function queue_free

lib_fiber/c/src/common/queue.c:70–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void queue_free(QUEUE *que, QUEUE_FREE_FN free_fn)
71{
72 QUEUE_ITEM *qi;
73 int status;
74
75 if (que == NULL) {
76 return;
77 }
78
79 if (que->check_owner && thread_self() != que->owner) {
80 msg_error("%s: cur tid(%lu) != owner(%lu)!", __FUNCTION__,
81 thread_self(), que->owner);
82 return;
83 }
84
85 que->quit = 1;
86 status = pthread_mutex_lock(&que->lock);
87 if (status != 0) {
88 msg_error("%s: lock error(%s)", __FUNCTION__, last_serror());
89 }
90
91 while (1) {
92 qi = que->first;
93 if (qi == NULL) {
94 break;
95 }
96 que->first = qi->next;
97 if (free_fn != NULL) {
98 free_fn(qi->data);
99 }
100 free(qi);
101 }
102
103 status = pthread_mutex_unlock(&que->lock);
104 if (status != 0) {
105 msg_error("%s: lock error(%s)", __FUNCTION__, last_serror());
106 }
107
108 pthread_mutex_destroy(&que->lock);
109 pthread_cond_destroy(&que->cond);
110 free(que);
111}
112
113static int queue_wait(QUEUE *que, const struct timespec *ptimeo)
114{

Callers

nothing calls this directly

Calls 8

thread_selfFunction · 0.85
pthread_mutex_lockFunction · 0.85
freeFunction · 0.85
pthread_mutex_unlockFunction · 0.85
pthread_mutex_destroyFunction · 0.85
msg_errorFunction · 0.70
last_serrorFunction · 0.70
free_fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…