merge job rusage and pending reason support

This commit is contained in:
Rongsong Shen 2025-12-16 14:36:28 +08:00
parent 30824ae5ea
commit cb0c7fe9e7
82 changed files with 4280 additions and 2561 deletions

View file

@ -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) {