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

Function queue_wait

lib_fiber/c/src/common/queue.c:113–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static int queue_wait(QUEUE *que, const struct timespec *ptimeo)
114{
115 int status;
116
117 while (que->first == NULL && que->quit == 0) {
118 if (ptimeo != NULL) {
119 status = pthread_cond_timedwait(&que->cond,
120 &que->lock, ptimeo);
121 } else {
122 status = pthread_cond_wait(&que->cond, &que->lock);
123 }
124
125 if (ptimeo && status == FIBER_ETIME) {
126 status = pthread_mutex_unlock(&que->lock);
127 if (status != 0) {
128 msg_error("%s(%d): unlock error(%s)",
129 __FUNCTION__, __LINE__, last_serror());
130 }
131
132 que->error = QUEUE_ERR_TIMEOUT;
133 return -1;
134 } else if (status != 0) {
135 status = pthread_mutex_unlock(&que->lock);
136 if (status != 0) {
137 msg_error("%s(%d): unlock error(%s)",
138 __FUNCTION__, __LINE__, last_serror());
139 }
140
141 que->error = QUEUE_ERR_COND_WAIT;
142 msg_error("%s: cond wait error(%s)",
143 __FUNCTION__, last_serror());
144 return -1;
145 }
146 }
147
148 return 0;
149}
150
151void *queue_pop_timedwait(QUEUE *que, int tmo_sec, int tmo_usec)
152{

Callers 1

queue_pop_timedwaitFunction · 0.85

Calls 3

pthread_mutex_unlockFunction · 0.85
msg_errorFunction · 0.70
last_serrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…