merge job rusage and pending reason support
This commit is contained in:
parent
30824ae5ea
commit
cb0c7fe9e7
82 changed files with 4280 additions and 2561 deletions
|
|
@ -161,6 +161,30 @@ int cbuf_get(cbuf_t* b, void* it)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cbuf_tryget(cbuf_t* b, void* it)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ((b == NULL) || (it == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&(b->mutex));
|
||||
if (b->len == 0) {
|
||||
rc = -EAGAIN;
|
||||
} else {
|
||||
memcpy(it, (void*)((char*)b->data) + b->isize * b->head, b->isize);
|
||||
|
||||
b->head = (b->head + 1) % b->ncap;
|
||||
b->len--;
|
||||
|
||||
pthread_cond_signal(&(b->condput));
|
||||
}
|
||||
pthread_mutex_unlock(&(b->mutex));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int my_rwlock_init(my_rwlock_t* l)
|
||||
{
|
||||
if (l == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue