本文整理匯總了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);
}
示例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);
// }
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例9: Assert
void TradeRouteData::SetRecip(TradeRoute route)
{
Assert(FALSE);
m_recip = route;
ENQUEUE();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}