當前位置: 首頁>>代碼示例>>C++>>正文


C++ ENQUEUE函數代碼示例

本文整理匯總了C++中ENQUEUE函數的典型用法代碼示例。如果您正苦於以下問題:C++ ENQUEUE函數的具體用法?C++ ENQUEUE怎麽用?C++ ENQUEUE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ENQUEUE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: push_readyq

/*
 * Push 'task' onto the ready_tasks queue.  If 'task' has the privilege
 * flag set, then also push it onto the ready_priority_tasks queue.
 *
 * Caller must hold the task manager lock.
 */
static inline void
push_readyq(isc__taskmgr_t *manager, isc__task_t *task) {
	ENQUEUE(manager->ready_tasks, task, ready_link);
	if ((task->flags & TASK_F_PRIVILEGED) != 0)
		ENQUEUE(manager->ready_priority_tasks, task,
			ready_priority_link);
}
開發者ID:execunix,項目名稱:vinos,代碼行數:13,代碼來源:task.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: AppMenuDoCommand

/* Perform menu command COMMAND.  */
Boolean
AppMenuDoCommand (UInt16 command)
{
    Boolean handled = false;
    FormDesc *fd;

    /* See if menu command is a form switch.  */
    for (fd = g_formList; fd; fd = fd->next) {
        if (fd->menuCommandID == command) {
            SwitchToForm (fd->formID);
            return true;
        }
    }

    /* Handle the rest of the items.  */
    switch (command) {
	case CommonOptionsPreferences:
	    PrefShowSetupForm();
	    return true;
	    
	case CommonOptionsAbout:
	    AboutShow();
	    return true;

#if 0
	case CommonOptionsSwitchclass:
	    SPREF (bluetoothClass) = (SPREF (bluetoothClass) + 1) % 5;
	    SPREF (bluetoothSDP) = (SPREF (bluetoothSDP) + 1) % 5;
	    return true;
#endif

	case CommonConnectionAddDevice:
	    BTSelectDevice();
	    return true;

	case CommonConnectionConnect:
	    ENQUEUE (CmdInitiateConnect);
	    return true;

	case CommonConnectionDisconnect:
	    ENQUEUE (CmdInitiateDisconnect);
	    return true;

	default:
	    break;
    }

    return handled;
}
開發者ID:fwindpeak,項目名稱:blue-remote,代碼行數:50,代碼來源:AppMenu.c

示例4: 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

示例5: 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

示例6: arc_event_handler

/*
Normal event handler.

Take first character off queue and send to clock if not a null.

Shift characters down and put a null on the end.

We assume that there is no parallelism so no race condition, but even
if there is nothing bad will happen except that we might send some bad
data to the clock once in a while.
*/
static void
arc_event_handler(
	struct peer *peer
	)
{
	struct refclockproc *pp = peer->procptr;
	register struct arcunit *up = (struct arcunit *)pp->unitptr;
	int i;
	char c;
#ifdef DEBUG
	if(debug > 2) { printf("arc: arc_event_handler() called.\n"); }
#endif

	c = up->cmdqueue[0];       /* Next char to be sent. */
	/* Shift down characters, shifting trailing \0 in at end. */
	for(i = 0; i < CMDQUEUELEN; ++i)
	{ up->cmdqueue[i] = up->cmdqueue[i+1]; }

	/* Don't send '\0' characters. */
	if(c != '\0') {
		if(write(pp->io.fd, &c, 1) != 1) {
			msyslog(LOG_NOTICE, "ARCRON: write to fd %d failed", pp->io.fd);
		}
#ifdef DEBUG
		else if(debug) { printf("arc: sent `%2.2x', fd %d.\n", c, pp->io.fd); }
#endif
	}

	ENQUEUE(up);
}
開發者ID:cyclops8456,項目名稱:ntp,代碼行數:41,代碼來源:refclock_arc.c

示例7: console_print

static fsm_rt_t console_print(const uint8_t *pchBuf,uint8_t chNum)
{
    static uint8_t s_chPrintIndex ;
    static enum {
        CONSOLE_PRT_START = 0,
        CONSOLE_PRT_PRINT
    }s_tState = CONSOLE_PRT_START;
    
    if((NULL == pchBuf) || (!chNum)) {
        return fsm_rt_err;
    }
    
    switch(s_tState) {
        case CONSOLE_PRT_START:
            s_chPrintIndex = 0;
            s_tState = CONSOLE_PRT_PRINT;
            //break;
            
        case CONSOLE_PRT_PRINT:
            if(s_chPrintIndex < chNum) {
                if(ENQUEUE(InOutQueue,&g_tFIFOout,pchBuf[s_chPrintIndex])) {
                    s_chPrintIndex++;
                }
            } else {
                CONSOLE_PRT_RESET();
                return fsm_rt_cpl;
            }
            break;
    }
    
    return fsm_rt_on_going;
}
開發者ID:aixiaoxianggithub,項目名稱:homework,代碼行數:32,代碼來源:console.c

示例8: task_send

static inline isc_boolean_t
task_send(isc_task_t *task, isc_event_t **eventp) {
	isc_boolean_t was_idle = ISC_FALSE;
	isc_event_t *event;

	/*
	 * Caller must be holding the task lock.
	 */

	REQUIRE(eventp != NULL);
	event = *eventp;
	REQUIRE(event != NULL);
	REQUIRE(event->ev_type > 0);
	REQUIRE(task->state != task_state_done);

	XTRACE("task_send");

	if (task->state == task_state_idle) {
		was_idle = ISC_TRUE;
		INSIST(EMPTY(task->events));
		task->state = task_state_ready;
	}
	INSIST(task->state == task_state_ready ||
	       task->state == task_state_running);
	ENQUEUE(task->events, event, ev_link);
	*eventp = NULL;

	return (was_idle);
}
開發者ID:OPSF,項目名稱:uClinux,代碼行數:29,代碼來源:task.c

示例9: Assert

void TradeRouteData::SetRecip(TradeRoute route)
{

	Assert(FALSE);

	m_recip = route;
	ENQUEUE();
}
開發者ID:jleclanche,項目名稱:darkdust-ctp2,代碼行數:8,代碼來源:TradeRouteData.cpp

示例10: TTY_WriteByte

int TTY_WriteByte(int handle, byte data)
{
	ComPort	*p;

	p = handleToPort [handle];
	if (FULL(p->outputQueue))
		return -1;

	ENQUEUE (p->outputQueue, data);
	return 0;
}
開發者ID:luaman,項目名稱:qforge-nuq,代碼行數:11,代碼來源:net_comx.c

示例11: Modem_Command

static int Modem_Command(ComPort *p, char *commandString)
{
	byte	b;

	if (CheckStatus (p))
		return -1;

	disable();
	p->outputQueue.head = p->outputQueue.tail = 0;
	p->inputQueue.head = p->inputQueue.tail = 0;
	enable();
	p->bufferUsed = 0;

	while (*commandString)
		ENQUEUE (p->outputQueue, *commandString++);
	ENQUEUE (p->outputQueue, '\r');

	// get the transmit rolling
	DEQUEUE (p->outputQueue, b);
	outportb(p->uart, b);

	return 0;
}
開發者ID:luaman,項目名稱:qforge-nuq,代碼行數:23,代碼來源:net_comx.c

示例12: processautorepeat

CARD32
processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg)
{
    xEvent kevent;
    int    keycode;

    keycode = (long)arg;

    xf86Info.lastEventTime =
	kevent.u.keyButtonPointer.time =
	    GetTimeInMillis();

    /*
     * Repeat a key by faking a KeyRelease, and a KeyPress event in rapid
     * succession
     */

    ENQUEUE(&kevent, keycode,  KeyRelease, XE_KEYBOARD);
    ENQUEUE(&kevent, keycode,  KeyPress, XE_KEYBOARD);

    /* And return the appropriate value so we get rescheduled */
    return xf86Info.kbdRate;
}
開發者ID:narenas,項目名稱:nx-libs,代碼行數:23,代碼來源:sun_kbdEv.c

示例13: GameObj

//----------------------------------------------------------------------------
//
// Name       : CivilisationData::CivilisationData
//
// Description: Constructor
//
// Parameters : id      : unique civilisation id
//              owner   : player index
//              civ     : civilisation index
//              gender  : leader gender
//
// Globals    : -
//
// Returns    : -
//
// Remark(s)  : Notifies other (network) players of its existence.
//
//----------------------------------------------------------------------------
CivilisationData::CivilisationData(const ID &id, PLAYER_INDEX owner, sint32 civ, GENDER gender)
:	GameObj(id.m_id),
	m_owner(owner),
	m_civ(civ),
	m_gender(gender),
	m_cityStyle(CITY_STYLE_GENERIC)
{
	memset(m_cityname_count, 0, sizeof(m_cityname_count));
	memset(m_leader_name, 0, k_MAX_NAME_LEN);
	memset(m_personality_description, 0, k_MAX_NAME_LEN);
	memset(m_civilisation_name, 0, k_MAX_NAME_LEN);
	memset(m_country_name, 0, k_MAX_NAME_LEN);
	memset(m_singular_name, 0, k_MAX_NAME_LEN);

	ENQUEUE();
}
開發者ID:jleclanche,項目名稱:darkdust-ctp2,代碼行數:34,代碼來源:CivilisationData.cpp

示例14: 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

示例15: task_ready

static inline void
task_ready(isc_task_t *task) {
	isc_taskmgr_t *manager = task->manager;

	REQUIRE(VALID_MANAGER(manager));
	REQUIRE(task->state == task_state_ready);

	XTRACE("task_ready");

	LOCK(&manager->lock);

	ENQUEUE(manager->ready_tasks, task, ready_link);
#ifdef ISC_PLATFORM_USETHREADS
	SIGNAL(&manager->work_available);
#endif /* ISC_PLATFORM_USETHREADS */

	UNLOCK(&manager->lock);
}
開發者ID:OPSF,項目名稱:uClinux,代碼行數:18,代碼來源:task.c


注:本文中的ENQUEUE函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。