本文整理汇总了C++中queue_empty函数的典型用法代码示例。如果您正苦于以下问题:C++ queue_empty函数的具体用法?C++ queue_empty怎么用?C++ queue_empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue_empty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: chg_pri
ER
chg_pri(ID tskid, PRI tskpri)
{
TCB *p_tcb;
uint_t newbpri;
ER ercd;
LOG_CHG_PRI_ENTER(tskid, tskpri);
CHECK_TSKCTX_UNL();
CHECK_TSKID_SELF(tskid);
CHECK_TPRI_INI(tskpri);
p_tcb = get_tcb_self(tskid);
CHECK_ACPTN(p_tcb->p_tinib->acvct.acptn2);
newbpri = (tskpri == TPRI_INI) ? p_tcb->p_tinib->ipriority
: INT_PRIORITY(tskpri);
if (rundom != TACP_KERNEL) {
CHECK_ILUSE(newbpri >= p_runtsk->p_tinib->p_dominib->minpriority);
}
t_lock_cpu();
if (TSTAT_DORMANT(p_tcb->tstat)) {
ercd = E_OBJ;
}
else if ((!queue_empty(&(p_tcb->mutex_queue))
|| TSTAT_WAIT_MTX(p_tcb->tstat))
&& !((*mtxhook_check_ceilpri)(p_tcb, newbpri))) {
ercd = E_ILUSE;
}
else {
p_tcb->bpriority = newbpri;
if (queue_empty(&(p_tcb->mutex_queue))
|| !((*mtxhook_scan_ceilmtx)(p_tcb))) {
if (change_priority(p_tcb, newbpri, false)) {
dispatch();
}
}
ercd = E_OK;
}
t_unlock_cpu();
error_exit:
LOG_CHG_PRI_LEAVE(ercd);
return(ercd);
}
示例2: hal_irq_alloc
errno_t hal_irq_alloc( int irq, void (*func)(void *arg), void *_arg, int is_shareable )
{
if( irq < 0 && irq >= MAX_IRQ_COUNT )
panic("IRQ %d > max %d", irq, MAX_IRQ_COUNT-1 );
if( (!is_shareable) && !queue_empty( &heads[irq] ) )
{
printf("IRQ %d asked exculsive, but other user exist", irq);
return EMLINK;
}
if( is_shareable && !queue_empty( &heads[irq] ) && (!((struct handler_q *)queue_first( &heads[irq] ))->is_shareable) )
{
printf("IRQ %d asked shared, but already exclusive", irq);
return EMLINK;
}
struct handler_q *out = malloc(sizeof(struct handler_q));
if(out == 0)
return ENOMEM;
out->ihandler = func;
out->arg = _arg;
out->is_shareable = is_shareable;
// mask off IRQ when modifying it's handlers list
board_interrupt_disable(irq);
int ie = hal_save_cli();
hal_spin_lock(&irq_list_lock);
// Queue insert is not atomic, will break
// if interrupt is executed on other CPU.
// That is why we disable irq on controller before doing this.
queue_enter(&heads[irq], out, struct handler_q *, chain);
// Do it in spinlock to avoid races with disable_irq
board_interrupt_enable(irq);
hal_spin_unlock(&irq_list_lock);
if(ie) hal_sti();
return 0;
}
示例3: do_read
static ssize_t do_read(struct file *fp, char *buf, size_t count, loff_t *ppos)
{
struct apm_user * as;
int i;
apm_event_t event;
DECLARE_WAITQUEUE(wait, current);
as = fp->private_data;
if (check_apm_user(as, "read"))
return -EIO;
if (count < sizeof(apm_event_t))
return -EINVAL;
if (queue_empty(as)) {
if (fp->f_flags & O_NONBLOCK)
return -EAGAIN;
add_wait_queue(&apm_waitqueue, &wait);
repeat:
set_current_state(TASK_INTERRUPTIBLE);
if (queue_empty(as) && !signal_pending(current)) {
schedule();
goto repeat;
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&apm_waitqueue, &wait);
}
i = count;
while ((i >= sizeof(event)) && !queue_empty(as)) {
event = get_queued_event(as);
if (copy_to_user(buf, &event, sizeof(event))) {
if (i < count)
break;
return -EFAULT;
}
buf += sizeof(event);
i -= sizeof(event);
}
if (i < count)
return count - i;
if (signal_pending(current))
return -ERESTARTSYS;
return 0;
}
示例4: wai_flg
ER
wai_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn)
{
FLGCB *p_flgcb;
WINFO_FLG *p_winfo_flg;
ER ercd;
PCB *my_p_pcb;
TCB *p_runtsk;
LOG_WAI_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn);
CHECK_TSKCTX_UNL();
CHECK_FLGID(flgid);
CHECK_PAR(waiptn != 0U);
CHECK_PAR(wfmode == TWF_ORW || wfmode == TWF_ANDW);
p_flgcb = get_flgcb(flgid);
t_lock_cpu();
my_p_pcb = get_my_p_pcb();
T_CHECK_DISPATCH(my_p_pcb);
retry:
t_acquire_obj_lock(&GET_OBJLOCK(p_flgcb));
if ((p_flgcb->p_flginib->flgatr & TA_WMUL) == 0U
&& !queue_empty(&(p_flgcb->wait_queue))) {
release_obj_lock(&GET_OBJLOCK(p_flgcb));
ercd = E_ILUSE;
}
else if (check_flg_cond(p_flgcb, waiptn, wfmode, p_flgptn)) {
release_obj_lock(&GET_OBJLOCK(p_flgcb));
ercd = E_OK;
}
else {
if ((my_p_pcb = t_acquire_nested_tsk_lock_self(&GET_OBJLOCK(p_flgcb))) == NULL){
goto retry;
}
p_runtsk = my_p_pcb->p_runtsk;
p_winfo_flg = (WINFO_FLG *)(&(p_runtsk->winfo_obj));
p_winfo_flg->waiptn = waiptn;
p_winfo_flg->wfmode = wfmode;
p_runtsk->tstat = (TS_WAITING | TS_WAIT_FLG);
wobj_make_wait((WOBJCB *) p_flgcb, p_runtsk);
release_nested_tsk_lock(my_p_pcb);
release_obj_lock(&GET_OBJLOCK(p_flgcb));
dispatch();
/* 値の参照だけなのでロックは必要ない */
ercd = p_runtsk->wercd;
if (ercd == E_OK) {
*p_flgptn = p_winfo_flg->flgptn;
}
}
t_unlock_cpu();
error_exit:
LOG_WAI_FLG_LEAVE(ercd, *p_flgptn);
return(ercd);
}
示例5: ter_tsk
ER
ter_tsk(ID tskid)
{
TCB *p_tcb;
bool_t dspreq = false;
ER ercd;
LOG_TER_TSK_ENTER(tskid);
CHECK_TSKCTX_UNL();
CHECK_TSKID(tskid);
p_tcb = get_tcb(tskid);
CHECK_NONSELF(p_tcb);
CHECK_ACPTN(p_tcb->p_tinib->acvct.acptn2);
t_lock_cpu();
if (TSTAT_DORMANT(p_tcb->tstat)) {
ercd = E_OBJ;
}
else {
if (TSTAT_RUNNABLE(p_tcb->tstat)) {
/*
* p_tcbは自タスクでないため,(シングルプロセッサでは)実
* 行状態でなく,make_non_runnable(p_tcb)でタスクディスパッ
* チが必要になることはない.
*/
(void) make_non_runnable(p_tcb);
}
else if (TSTAT_WAITING(p_tcb->tstat)) {
if (wait_dequeue_wobj(p_tcb)) {
dspreq = true;
}
wait_dequeue_tmevtb(p_tcb);
}
if (!queue_empty(&(p_tcb->mutex_queue))) {
if ((*mtxhook_release_all)(p_tcb)) {
dspreq = true;
}
}
make_dormant(p_tcb);
if (p_tcb->actque) {
p_tcb->actque = false;
if (make_active(p_tcb)) {
dspreq = true;
}
}
if (dspreq) {
dispatch();
}
ercd = E_OK;
}
t_unlock_cpu();
error_exit:
LOG_TER_TSK_LEAVE(ercd);
return(ercd);
}
示例6: bit_semaphore
static ER
bit_semaphore(ID semid)
{
SEMCB *p_semcb;
const SEMINIB *p_seminib;
uint_t semcnt;
QUEUE *p_queue;
TCB *p_tcb;
if (!(TMIN_SEMID <= (semid) && (semid) <= tmax_semid)) {
return(E_ID);
}
p_semcb = get_semcb(semid);
p_seminib = p_semcb->p_seminib;
semcnt = p_semcb->semcnt;
/*
* 初期化ブロックへのポインタの検査
*/
if (p_seminib != &(seminib_table[INDEX_SEM(semid)])) {
return(E_SYS_LINENO);
}
/*
* semcntの検査
*/
if (semcnt > p_seminib->maxsem) {
return(E_SYS_LINENO);
}
/*
* wait_queueの検査
*/
if (semcnt == 0) {
p_queue = p_semcb->wait_queue.p_next;
while (p_queue != &(p_semcb->wait_queue)) {
p_tcb = (TCB *) p_queue;
p_queue = p_queue->p_next;
if (!VALID_TCB(p_tcb)) {
return(E_SYS_LINENO);
}
if (p_tcb->tstat != (TS_WAITING | TS_WAIT_SEM)) {
return(E_SYS_LINENO);
}
if (p_semcb != ((WINFO_SEM *)(p_tcb->p_winfo))->p_semcb) {
return(E_SYS_LINENO);
}
}
}
else {
if (!queue_empty(&(p_semcb->wait_queue))) {
return(E_SYS_LINENO);
}
}
return(E_OK);
}
示例7: dequeue
int dequeue (queue_t *buf, int *data) {
//int data = 0;
if(queue_empty(buf))
return 0;
else {
*data = buf->buffer[buf->head];
buf->head = ((buf->head +1) == QUEUE_SIZE) ? 0 : buf->head + 1;
}
return 1;
}
示例8: solvable_lookup_deparray
int
solvable_lookup_deparray(Solvable *s, Id keyname, Queue *q, Id marker)
{
if (!s->repo)
{
queue_empty(q);
return 0;
}
return repo_lookup_deparray(s->repo, s - s->repo->pool->solvables, keyname, q, marker);
}
示例9: dequeue_single
int dequeue_single(struct queue_stub *stub,struct queue_element*ele)
{
if(queue_empty(stub))
return -1;
ele->rte_pkt_offset=stub->records[stub->front_ptr].rte_pkt_offset;
ele->rte_data_offset=stub->records[stub->front_ptr].rte_data_offset;
WRITE_MEM_WB();
stub->front_ptr=(stub->front_ptr+1)%(stub->ele_num+1);
return 0;
}
示例10: display_queue_int
/**
* \fn void display_queue_int(queue q);
* \brief Used to display the content of a queue as if they were integers.
* \details This function is non-destructive.
* \param q The queue to display.
*/
void display_queue_int(queue q){
direction cur_elt;
printf("< ");
while(!queue_empty(&q)){
cur_elt = dequeue(&q);
printf("%i ", cur_elt);
}
printf("<\n");
}
示例11: poll_qp
unsigned int poll_qp(struct file *file, poll_table * wait)
{
int temp_1;
poll_wait(file, &queue->proc_list, wait);
temp_1 = queue_empty();
if (!temp_1)
return (0x0001 | 0x0040) ;
return 0;
}
示例12: dequeue
int dequeue (queue_t *buf) {
int result;
if(queue_empty(buf)){
return 0;
} else {
result = buf->buffer[buf->tail];
buf->tail = ((buf->tail + 1) == QUEUE_SIZE) ? 0 : buf->tail + 1;
}
return result;
}
示例13: handle_events
void handle_events (queue_t q)
{
queue_entry_t event;
while (!queue_empty (q))
{
event = queue_dequeue (q);
handle_event (event);
free (event);
}
}
示例14: queue_push
void queue_push(QUEUE q, VALUE v) {
if (queue_empty(q)) {
q->head = q->tail = make_queue_node(v, NULL, NULL);
}
else {
QUEUE_NODE n = make_queue_node(v, tail, NULL);
q->tail->next = n;
q->tail = n;
}
}
示例15: async_cb
static void async_cb(uv_async_t *handle)
{
Loop *l = handle->loop->data;
uv_mutex_lock(&l->mutex);
while (!queue_empty(l->thread_events)) {
Event ev = queue_get(l->thread_events);
queue_put_event(l->fast_events, ev);
}
uv_mutex_unlock(&l->mutex);
}