当前位置: 首页>>代码示例>>C++>>正文


C++ DEQUEUE函数代码示例

本文整理汇总了C++中DEQUEUE函数的典型用法代码示例。如果您正苦于以下问题:C++ DEQUEUE函数的具体用法?C++ DEQUEUE怎么用?C++ DEQUEUE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DEQUEUE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isc_condition_destroy

isc_result_t
isc_condition_destroy(isc_condition_t *cond) {

	isc_condition_thread_t *next, *threadcond;

	REQUIRE(cond != NULL);
	REQUIRE(cond->waiters == 0);

	(void)CloseHandle(cond->events[LSIGNAL]);

	/*
	 * Delete the threadlist
	 */
	threadcond = ISC_LIST_HEAD(cond->threadlist);

	while (threadcond != NULL) {
		next = ISC_LIST_NEXT(threadcond, link);
		DEQUEUE(cond->threadlist, threadcond, link);
		(void) CloseHandle(threadcond->handle[LBROADCAST]);
		free(threadcond);
		threadcond = next;
	}

	return (ISC_R_SUCCESS);
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:25,代码来源:condition.c

示例2: dijkstra

void dijkstra(struct Graph *G, int s) {
    struct Queue* Q;
    Q = (struct Queue*)malloc(sizeof(struct Queue));
    Q->length = MAX_SIZE - 1;
    Q->head = Q->tail = 0;

    int i, j;
    G->costArray[s] = 0;

    ENQUEUE(Q, s);

    while(Q->head!=Q->tail) {      
        j = DEQUEUE(Q);
        G->colorArray[j] = BLACK;
        for (i=1; i<=G->V; i++) {
            if (G->adjMatrix[i][j]==0) {continue;} // Not j's neighbors
            else {
           //     if (G->colorArray[i]!=BLACK) { // Not j's parent
                    if (G->costArray[i]==INFINITE) { // New node
                        G->costArray[i] = G->costArray[j] + G->adjMatrix[i][j];
                        G->parentArray[i] = j;
                    }
                    else if (G->costArray[i] > G->costArray[j] + G->adjMatrix[i][j]) { // Updated node
                        G->costArray[i] = G->costArray[j] + G->adjMatrix[i][j];
                        G->parentArray[i] = j;
                    }
                    ENQUEUE(Q, i);
             //   }
            }
        }
    }
}
开发者ID:OrkoHunter,项目名称:algo-lab-records,代码行数:32,代码来源:dijkstra.c

示例3: isc__task_setprivilege

ISC_TASKFUNC_SCOPE void
isc__task_setprivilege(isc_task_t *task0, isc_boolean_t priv) {
	isc__task_t *task = (isc__task_t *)task0;
	isc__taskmgr_t *manager = task->manager;
	isc_boolean_t oldpriv;

	LOCK(&task->lock);
	oldpriv = ISC_TF((task->flags & TASK_F_PRIVILEGED) != 0);
	if (priv)
		task->flags |= TASK_F_PRIVILEGED;
	else
		task->flags &= ~TASK_F_PRIVILEGED;
	UNLOCK(&task->lock);

	if (priv == oldpriv)
		return;

	LOCK(&manager->lock);
	if (priv && ISC_LINK_LINKED(task, ready_link))
		ENQUEUE(manager->ready_priority_tasks, task,
			ready_priority_link);
	else if (!priv && ISC_LINK_LINKED(task, ready_priority_link))
		DEQUEUE(manager->ready_priority_tasks, task,
			ready_priority_link);
	UNLOCK(&manager->lock);
}
开发者ID:execunix,项目名称:vinos,代码行数:26,代码来源:task.c

示例4: while

static char *Modem_Response(ComPort *p)
{
	byte	b;

	if (CheckStatus (p))
		return NULL;

	while (! EMPTY(p->inputQueue))
	{
		DEQUEUE (p->inputQueue, b);

		if (p->bufferUsed == (sizeof(p->buffer) - 1))
			b = '\r';

		if (b == '\r' && p->bufferUsed)
		{
			p->buffer[p->bufferUsed] = 0;
			Con_Printf("%s\n", p->buffer);
			SCR_UpdateScreen ();
			p->bufferUsed = 0;
			return p->buffer;
		}

		if (b < ' ' || b > 'z')
			continue;
		p->buffer[p->bufferUsed] = b;
		p->bufferUsed++;
	}

	return NULL;
}
开发者ID:luaman,项目名称:qforge-nuq,代码行数:31,代码来源:net_comx.c

示例5: pop_readyq

/*
 * Dequeue and return a pointer to the first task on the current ready
 * list for the manager.
 * If the task is privileged, dequeue it from the other ready list
 * as well.
 *
 * Caller must hold the task manager lock.
 */
static inline isc__task_t *
pop_readyq(isc__taskmgr_t *manager) {
	isc__task_t *task;

	if (manager->mode == isc_taskmgrmode_normal)
		task = HEAD(manager->ready_tasks);
	else
		task = HEAD(manager->ready_priority_tasks);

	if (task != NULL) {
		DEQUEUE(manager->ready_tasks, task, ready_link);
		if (ISC_LINK_LINKED(task, ready_priority_link))
			DEQUEUE(manager->ready_priority_tasks, task,
				ready_priority_link);
	}

	return (task);
}
开发者ID:execunix,项目名称:vinos,代码行数:26,代码来源:task.c

示例6: main

int main (void)
{
    s_version_assert (2, 1);

    //  Prepare our context and sockets
    void *context = zmq_init (1);
    void *frontend = zmq_socket (context, ZMQ_XREP);
    void *backend  = zmq_socket (context, ZMQ_XREP);
    zmq_bind (frontend, "tcp://*:5555");    //  For clients
    zmq_bind (backend,  "tcp://*:5556");    //  For workers

    //  Queue of available workers
    int available_workers = 0;
    char *worker_queue [MAX_WORKERS];

    while (1) {
        zmq_pollitem_t items [] = {
            { backend,  0, ZMQ_POLLIN, 0 },
            { frontend, 0, ZMQ_POLLIN, 0 }
        };
        //  Poll frontend only if we have available workers
        if (available_workers)
            zmq_poll (items, 2, -1);
        else
            zmq_poll (items, 1, -1);

        //  Handle worker activity on backend
        if (items [0].revents & ZMQ_POLLIN) {
            zmsg_t *zmsg = zmsg_recv (backend);
            //  Use worker address for LRU routing
            assert (available_workers < MAX_WORKERS);
            worker_queue [available_workers++] = zmsg_unwrap (zmsg);

            //  Return reply to client if it's not a READY
            if (strcmp (zmsg_address (zmsg), "READY") == 0)
                zmsg_destroy (&zmsg);
            else
                zmsg_send (&zmsg, frontend);
        }
        if (items [1].revents & ZMQ_POLLIN) {
            //  Now get next client request, route to next worker
            zmsg_t *zmsg = zmsg_recv (frontend);
            //  REQ socket in worker needs an envelope delimiter
            zmsg_wrap (zmsg, worker_queue [0], "");
            zmsg_send (&zmsg, backend);

            //  Dequeue and drop the next worker address
            free (worker_queue [0]);
            DEQUEUE (worker_queue);
            available_workers--;
        }
    }
    //  We never exit the main loop
    return 0;
}
开发者ID:tzuryby,项目名称:zguide,代码行数:55,代码来源:spqueue.c

示例7: TTY_Flush

void TTY_Flush(int handle)
{
	byte b;
	ComPort	*p;

	p = handleToPort [handle];

	if (inportb (p->uart + LINE_STATUS_REGISTER ) & LSR_TRANSMITTER_EMPTY)
	{
		DEQUEUE (p->outputQueue, b);
		outportb(p->uart, b);
	}
}
开发者ID:luaman,项目名称:qforge-nuq,代码行数:13,代码来源:net_comx.c

示例8: console_check

static fsm_rt_t console_check(void)
{
    static uint8_t s_chTemp = 0;
    static uint8_t s_chNum  = 0;
    static uint8_t *s_pchPRT = NULL;
    static enum {
        CONSOLE_CHECK_START = 0,
        CONSOLE_CHECK_CMD,
        CONSOLE_CHECK_PRT,
    }s_tState;
    
    switch(s_tState) {
        case CONSOLE_CHECK_START:
            s_pchPRT = NULL;
            s_tState = CONSOLE_CHECK_CMD;
            //break;
            
        case CONSOLE_CHECK_CMD:
            if(DEQUEUE(InOutQueue,&g_tFIFOin,&s_chTemp)) {
                if ((s_chTemp >= 32) && (s_chTemp <= 127) ){
                    if(s_chCmdBufIndex >= CONSOLE_BUF_SIZE) {
                        break;
                    }
                    s_chCmdBuf[s_chCmdBufIndex++] = s_chTemp;
                    s_pchPRT = &s_chTemp;
                    s_chNum = 1;
                } else if('\r' == s_chTemp ) {
                    COSOLE_CHECK_RESET();
                    return fsm_rt_cpl;
                } else if('\b' == s_chTemp ){
                    if(s_chCmdBufIndex <= 2) {
                        break;
                    }
                    s_chCmdBufIndex--;
                    s_pchPRT = (uint8_t*)c_chDelChar;
                    s_chNum = UBOUND(c_chDelChar);
                }
                s_tState = CONSOLE_CHECK_PRT;
            }
            break;
        
        case CONSOLE_CHECK_PRT:
            if(fsm_rt_cpl == console_print(s_pchPRT,s_chNum)) {
                s_tState = CONSOLE_CHECK_CMD;
            }
            break;
    }
    
    return fsm_rt_on_going;
}
开发者ID:aixiaoxianggithub,项目名称:homework,代码行数:50,代码来源:console.c

示例9: Topologicalsort

void Topologicalsort( AdjGraph G, int aov[NumVertices] )
{  
	int v, w, nodes;
	EdgeNode *tmp;
	EdgeData indegree[NumVertices+1]={0};

	QUEUE Q ;
	MAKENULL( Q ) ;

	// 计算每个顶点的入度
	for( v=1; v<=G.n ; ++v )
	{
		tmp=G.vexlist[v].firstedge;
		while(tmp)
		{
			indegree[tmp->adjvex]++;
			tmp=tmp->next;
		}	
	}
	// 将入度为0的顶点加入队列
	for(v=1; v<=G.n; ++v)
		if ( indegree[v] ==0 ) 
			ENQUEUE( v, Q ) ;
	
	nodes = 0 ;
	while ( !EMPTY( Q ) )
	{  
		v = FRONT(Q)->element ;
		DEQUEUE( Q ) ;
		//cout << v <<' '; 
		aov[nodes]=v;
		nodes ++ ;		// 已考虑的节点个数加1
		// 如果(v, w)是一条边,将w的入度减1,如果w的入度为0,则将w入队
		for( w=1; w<=G.n; w++) 
		{
			if(connect(G, v, w))
			{
				--indegree[w];
				if( !(indegree[w])) 
					ENQUEUE(w,Q) ;
			}
		}
	}
	cout<<endl;
	if ( nodes < G.n ) 
		cout<<"图中有环路"<<endl;
	
}
开发者ID:jiangxh1992,项目名称:Data-Structure-and-Algorithm,代码行数:48,代码来源:aov.cpp

示例10: TTY_ReadByte

int TTY_ReadByte(int handle)
{
	int		ret;
	ComPort	*p;

	p = handleToPort [handle];

	if ((ret = CheckStatus (p)) != 0)
		return ret;
	
	if (EMPTY (p->inputQueue))
		return ERR_TTY_NODATA;

	DEQUEUE (p->inputQueue, ret);
	return (ret & 0xff);
}
开发者ID:luaman,项目名称:qforge-nuq,代码行数:16,代码来源:net_comx.c

示例11: ISR_8250

static void ISR_8250 (ComPort *p)
{
	byte	source = 0;
	byte	b;

	disable();

	while((source = inportb (p->uart + INTERRUPT_ID_REGISTER) & 0x07) != 1)
	{
		switch (source)
		{
			case IIR_RX_DATA_READY_INTERRUPT:
				b = inportb (p->uart + RECEIVE_BUFFER_REGISTER);
				if (! FULL(p->inputQueue))
				{
					ENQUEUE (p->inputQueue, b);
				}
				else
				{
					p->lineStatus |= LSR_OVERRUN_ERROR;
					p->statusUpdated = true;
				}
				break;

			case IIR_TX_HOLDING_REGISTER_INTERRUPT:
				if (! EMPTY(p->outputQueue))
				{
					DEQUEUE (p->outputQueue, b);
					outportb (p->uart + TRANSMIT_HOLDING_REGISTER, b);
				}
				break;

			case IIR_MODEM_STATUS_INTERRUPT:
				p->modemStatus = (inportb (p->uart + MODEM_STATUS_REGISTER) & MODEM_STATUS_MASK) | p->modemStatusIgnore;
				p->statusUpdated = true;
				break;

			case IIR_LINE_STATUS_INTERRUPT:
				p->lineStatus = inportb (p->uart + LINE_STATUS_REGISTER);
				p->statusUpdated = true;
				break;
		}
		source = inportb (p->uart + INTERRUPT_ID_REGISTER) & 0x07;
	}
	outportb (0x20, 0x20);
}
开发者ID:luaman,项目名称:qforge-nuq,代码行数:46,代码来源:net_comx.c

示例12: check_func_key

fsm_rt_rt check_func_key(uint8_t chKeyTemp,uint8_t *pchKeyCode)
{
    static uint8_t s_chIndex ;
    
    switch(s_tState) {
        case FUNC_KEY_CHECK_START:
            s_chIndex = 0;
            s_tState = FUNC_KEY_CHECK_FIRST;
            //break;
        case FUNC_KEY_CHECK_FIRST:
            do {
                if( chKeyTemp == chFunKeyCode[s_chIndex]) {
                  s_tState = FUNC_KEY_CHECK_SECOND;
                  s_chIndex = 2 + 1 << s_chIndex ;
                  break;
                }
            } while(s_chIndex++ < 2);
            s_chIndex = 0;
            break;
            
        case FUNC_KEY_CHECK_SECOND:{
            uint8_t chIndex = 0;
            do {
                if( chKeyTemp == chFunKeyCode[s_chIndex]) {
                 *pchKeyCode = s_chIndex;
                  return fsm_rt_cpl;
                  break;
                }
                s_chIndex += chIndex;
            } while(chIndex++ < 4);
            break;
            
        case FUNC_KEY_CHECK_FAIL:
            FUNC_KEY_CHECK_RESET();
            RESET_PEEK();
            DEQUEUE();
            *pchKeyCode = KEY_ESC;
            //realse_s;
            return fsm_rt_cpl;
        }
    }
    
    return fsm_rt_on_going;
}
开发者ID:aixiaoxianggithub,项目名称:homework,代码行数:44,代码来源:console.c

示例13: isc__task_purgeevent

ISC_TASKFUNC_SCOPE isc_boolean_t
isc__task_purgeevent(isc_task_t *task0, isc_event_t *event) {
	isc__task_t *task = (isc__task_t *)task0;
	isc_event_t *curr_event, *next_event;

	/*
	 * Purge 'event' from a task's event queue.
	 *
	 * XXXRTH:  WARNING:  This method may be removed before beta.
	 */

	REQUIRE(VALID_TASK(task));

	/*
	 * If 'event' is on the task's event queue, it will be purged,
	 * unless it is marked as unpurgeable.  'event' does not have to be
	 * on the task's event queue; in fact, it can even be an invalid
	 * pointer.  Purging only occurs if the event is actually on the task's
	 * event queue.
	 *
	 * Purging never changes the state of the task.
	 */

	LOCK(&task->lock);
	for (curr_event = HEAD(task->events);
	     curr_event != NULL;
	     curr_event = next_event) {
		next_event = NEXT(curr_event, ev_link);
		if (curr_event == event && PURGE_OK(event)) {
			DEQUEUE(task->events, curr_event, ev_link);
			break;
		}
	}
	UNLOCK(&task->lock);

	if (curr_event == NULL)
		return (ISC_FALSE);

	isc_event_free(&curr_event);

	return (ISC_TRUE);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:42,代码来源:task.c

示例14: yaml_emitter_delete

yaml_emitter_delete(yaml_emitter_t *emitter)
{
    assert(emitter);    /* Non-NULL emitter object expected. */

    BUFFER_DEL(emitter, emitter->buffer);
    BUFFER_DEL(emitter, emitter->raw_buffer);
    STACK_DEL(emitter, emitter->states);
    while (!QUEUE_EMPTY(emitter, emitter->events)) {
        yaml_event_delete(&DEQUEUE(emitter, emitter->events));
    }
    QUEUE_DEL(emitter, emitter->events);
    STACK_DEL(emitter, emitter->indents);
    while (!STACK_EMPTY(empty, emitter->tag_directives)) {
        yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
        yaml_free(tag_directive.handle);
        yaml_free(tag_directive.prefix);
    }
    STACK_DEL(emitter, emitter->tag_directives);
    yaml_free(emitter->anchors);

    memset(emitter, 0, sizeof(yaml_emitter_t));
}
开发者ID:Dar13,项目名称:lightship,代码行数:22,代码来源:api.c

示例15: dequeue_events

static unsigned int
dequeue_events(isc_task_t *task, void *sender, isc_eventtype_t first,
	       isc_eventtype_t last, void *tag,
	       isc_eventlist_t *events, isc_boolean_t purging)
{
	isc_event_t *event, *next_event;
	unsigned int count = 0;

	REQUIRE(VALID_TASK(task));
	REQUIRE(last >= first);

	XTRACE("dequeue_events");

	/*
	 * Events matching 'sender', whose type is >= first and <= last, and
	 * whose tag is 'tag' will be dequeued.  If 'purging', matching events
	 * which are marked as unpurgable will not be dequeued.
	 *
	 * sender == NULL means "any sender", and tag == NULL means "any tag".
	 */

	LOCK(&task->lock);

	for (event = HEAD(task->events); event != NULL; event = next_event) {
		next_event = NEXT(event, ev_link);
		if (event->ev_type >= first && event->ev_type <= last &&
		    (sender == NULL || event->ev_sender == sender) &&
		    (tag == NULL || event->ev_tag == tag) &&
		    (!purging || PURGE_OK(event))) {
			DEQUEUE(task->events, event, ev_link);
			ENQUEUE(*events, event, ev_link);
			count++;
		}
	}

	UNLOCK(&task->lock);

	return (count);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:39,代码来源:task.c


注:本文中的DEQUEUE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。