本文整理汇总了C++中queue_pop函数的典型用法代码示例。如果您正苦于以下问题:C++ queue_pop函数的具体用法?C++ queue_pop怎么用?C++ queue_pop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue_pop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: proceed
static int proceed(h2o_http2_scheduler_node_t *node, h2o_http2_scheduler_run_cb cb, void *cb_arg)
{
Redo:
if (node->_queue == NULL)
return 0;
h2o_http2_scheduler_queue_node_t *drr_node = queue_pop(node->_queue);
if (drr_node == NULL)
return 0;
h2o_http2_scheduler_openref_t *ref = H2O_STRUCT_FROM_MEMBER(h2o_http2_scheduler_openref_t, _queue_node, drr_node);
if (!ref->_self_is_active) {
/* run the children (manually-unrolled tail recursion) */
queue_set(node->_queue, &ref->_queue_node, ref->weight);
node = &ref->node;
goto Redo;
}
assert(ref->_active_cnt != 0);
/* call the callbacks */
int still_is_active, bail_out = cb(ref, &still_is_active, cb_arg);
if (still_is_active) {
queue_set(node->_queue, &ref->_queue_node, ref->weight);
} else {
ref->_self_is_active = 0;
if (--ref->_active_cnt != 0) {
queue_set(node->_queue, &ref->_queue_node, ref->weight);
} else if (ref->node._parent != NULL) {
decr_active_cnt(ref->node._parent);
}
}
return bail_out;
}
开发者ID:ConfusedReality,项目名称:h2o,代码行数:35,代码来源:scheduler.c
示例2: sched_handler_try_steal
void sched_handler_try_steal(scheduler_t* scheduler, int steal_attempts) {
if (schedulers_nr > 1) {
unsigned int seed = 42;
srand(time(NULL));
long victim_id = 0;
int attempt = 0;
task_t* stolen = NULL;
while (stolen == NULL && attempt < steal_attempts) {
do {
victim_id = rand_r(&seed) % schedulers_nr;
} while (victim_id == scheduler->id);
scheduler_t* victim = &schedulers[victim_id];
stolen = queue_pop(&victim->ready);
if (stolen) {
debug("%d - yay", scheduler->id);
}
attempt+=1;
}
if (stolen) {
debug("%d - Succesfully stolen task %d from victim %d", scheduler->id, stolen->id, (int) victim_id);
scheduler->action = YIELD;
scheduler->current_task = stolen;
} else {
//debug("%d - Failed to steal from victim %d", scheduler->id, (int) victim_id);
}
}
}
开发者ID:bvancea,项目名称:spospl,代码行数:29,代码来源:task.c
示例3: stackPush
/* Push element x onto stack */
void stackPush(Stack *stack, int element) {
while(!queue_empty(&stack->q[stack->cur])) {
int x = queue_pop(&stack->q[stack->cur]);
queue_push(&stack->q[(stack->cur+1)%2], x);
}
queue_push(&stack->q[stack->cur], element);
}
开发者ID:tiancaiamao,项目名称:leetcode,代码行数:8,代码来源:225.c
示例4: malloc
/**
* @brief This thread represents a print spooler which directly talks to a single printer
* @param param
* The PRINT_SPOOL_PARAM this printer should pull its jobs from, casted to a void*
* @return NULL
*
* This function should loop forever. The basic process is as follows:
* 1) pop a print job from this threads queue
* 2) if it is NULL return
* 3) print to the log file that printing of the job is starting
* 4) call the print method on the printer object of the param and check the return
* 5) handel errors correctly
* 6) destroy the print job and get the next
*/
void *spooler(void* param)
{
struct PRINTER_SPOOLER_PARAM* params = malloc(sizeof(struct PRINTER_SPOOLER_PARAM));
params = (struct PRINTER_SPOOLER_PARAM*)param;
queue_t queue = params->print_queue_list;
printer_t printer = params->printer_driver;
struct arguments arguments = params->arguments;
queue_ends_t q_ends = QUEUE_HEAD;
print_job_t* popped;
FILE *file;
char *str;
while(1){
popped = queue_pop(queue, q_ends);
if (popped == NULL){
printer_uninstall(printer);
return NULL;
}
file = fopen(arguments.log_file_name, "a");
if(file == NULL){
fprintf(stderr, "%s: error opening log file\n", __func__);
exit(-1);
}
asprintf(&str, "Starting to print job %s\n", popped->job_name);
fputs(str,file);
fclose(file);
printer_print(printer, popped);
}
}
开发者ID:mattmckillip,项目名称:Cpre308,代码行数:45,代码来源:main.c
示例5: esta_bien_armada
bool esta_bien_armada() {
/*Esta correctamente armada si tiene todos los ingredientes,
* y los tiene definidos en el orden dado por el enum t_Ingredientes*/
for (int i = 0; (((t_Ingredientes) i) <= PANSUPERIOR); i++) {
t_Ingredientes ingrediente_correcto = (t_Ingredientes) i;
t_Ingredientes ingrediente_hamburguesa;
pthread_mutex_lock(&mutex);
int* ingrediente = queue_pop(hamburguesa.ingredientes);
pthread_mutex_unlock(&mutex);
if (ingrediente == NULL) {
printf("Faltaron ingredientes!\n");
return false;
}
ingrediente_hamburguesa = (t_Ingredientes) *ingrediente;
if (ingrediente_hamburguesa != ingrediente_correcto) {
printf("Ingrediente incorrecto debia ser %s y era %s\n",
ingrediente_to_string(ingrediente_correcto),
ingrediente_to_string(ingrediente_hamburguesa));
free(ingrediente);
return false;
}
}
return true;
}
开发者ID:1168392,项目名称:exercises,代码行数:30,代码来源:Wendys.c
示例6: ResThreads
void* ResThreads(void* empty)
{
char* outhostname; //hostname you pop off the queue
char firstipstring[INET6_ADDRSTRLEN];
//while the search is incomplete or the queue is not empty
while (!queue_is_empty(requesterQ) || !SearchComplete)
{
//if queue is empty wait
while (queue_is_empty(requesterQ)){
if(SearchComplete)
{
free(outhostname);
return 0;
}
}
//if there is an item in the queue, pop
pthread_mutex_lock(&Q_lock);//lock to have exclusion
outhostname = queue_pop(requesterQ); //hostname
pthread_mutex_unlock(&Q_lock);
//Lookup hostname and get IP string
if(dnslookup(outhostname, firstipstring, sizeof(firstipstring)) == UTIL_FAILURE)
{
fprintf(stderr, "dnslookup error: %s\n", outhostname);
strncpy(firstipstring, "", sizeof(firstipstring));
}
//Write to output file
pthread_mutex_lock( &Out_lock ); //Lock the outputfile so you only put one thing at a time in it
fprintf(outputfp, "%s,%s\n", outhostname, firstipstring);
free(outhostname);
pthread_mutex_unlock( &Out_lock );
}
return 0;
}
开发者ID:entzel,项目名称:Dnslookup,代码行数:35,代码来源:multilookup.c
示例7: queue_destroy
void queue_destroy(queue *Q)
{
while(!queue_empty(Q))
{
queue_pop(Q);
}
}
开发者ID:aa838260772,项目名称:linux-study,代码行数:7,代码来源:my_queue.c
示例8: threadDispositivo
void threadDispositivo(stDispositivo* unDispositivo) {
int error = 0;
t_queue *colaRafaga;
stRafaga *unaRafaga;
stPCB *unPCB;
colaRafaga = unDispositivo->rafagas;
while (!error) {
while (unDispositivo->numInq == 0)
pthread_mutex_lock(&unDispositivo->empty);
pthread_mutex_lock(&unDispositivo->mutex); // Se lockea el acceso a la cola
unaRafaga = queue_pop(colaRafaga);
unDispositivo->numInq--;
pthread_mutex_unlock(&unDispositivo->mutex); // Se desbloquea el acceso a la cola
log_info("Pedido I/O - Retardo de dispositivo [%s] con [%d].",unDispositivo->nombre,atoi(unDispositivo->retardo));
usleep(atoi(unDispositivo->retardo)*unaRafaga->unidades*1000);
/*Busqueda del pcb en la lista de pcb bloqueados*/
int _es_el_pcb(stPCB *p) {
return p->pid == unaRafaga->pid;
}
pthread_mutex_lock(&mutex_listaBlock);
unPCB = list_remove_by_condition(listaBlock, (void*) _es_el_pcb);
pthread_mutex_unlock(&mutex_listaBlock);
/*Ponemos en la cola de Ready para que lo vuelva a ejecutar un CPU*/
ready_productor(unPCB);
log_info("El PCB [PID - %d] cambia de estado BLOCK a READY\n", unPCB->pid);
free(unaRafaga);
}
}
开发者ID:nicolas-alejandro-pini,项目名称:tp-2016-1c-WorstPractices,代码行数:34,代码来源:Nucleo.c
示例9: command
static void
command(struct skynet_context *ctx, struct package *P, int session, uint32_t source, const char *msg, size_t sz) {
switch (msg[0]) {
case 'R':
// request a package
if (P->closed) {
skynet_send(ctx, 0, source, PTYPE_ERROR, session, NULL, 0);
break;
}
if (!queue_empty(&P->response)) {
assert(queue_empty(&P->request));
struct response resp;
queue_pop(&P->response, &resp);
skynet_send(ctx, 0, source, PTYPE_RESPONSE | PTYPE_TAG_DONTCOPY, session, resp.msg, resp.sz);
} else {
struct request req;
req.source = source;
req.session = session;
queue_push(&P->request, &req);
}
break;
case 'K':
// shutdown the connection
skynet_socket_shutdown(ctx, P->fd);
break;
case 'I':
report_info(ctx, P, session, source);
break;
default:
// invalid command
skynet_error(ctx, "Invalid command %.*s", (int)sz, msg);
skynet_send(ctx, 0, source, PTYPE_ERROR, session, NULL, 0);
break;
};
}
开发者ID:cloudwu,项目名称:skynet_package,代码行数:35,代码来源:service_package.c
示例10: application_exec
si_t application_exec()
{
/**
* parse the application before execute
**/
application_parse();
event_listener_add_read_event(&global_application.app_event_listener, &global_application.uds, NULL, application_event_handler, NULL);
while(!queue_empty(&global_application.message_queue))
{
union message* msg = queue_front(&global_application.message_queue);
application_handle_message(msg);
queue_pop(&global_application.message_queue);
}
global_application.exec_flag = 1;
if(0 != event_listener_exec(&global_application.app_event_listener))
{
EGUI_PRINT_ERROR("failed to run event_listener.");
return -1;
}
global_application.exec_flag = 0;
return 0;
}
开发者ID:FangKuangKuang,项目名称:egui,代码行数:26,代码来源:exec.c
示例11: application_event_handler
si_t application_event_handler(struct egui_uds* uds_ptr, addr_t arg)
{
union message msg;
NOT_USED(arg);
if(0 != comm_recv_msg(uds_ptr, &msg))
{
EGUI_PRINT_ERROR("failed to recv msg");
return SELECTER_RETURN_TYPE_CONTINUE;
}
application_handle_message(&msg);
/**
* 处理器消息过程中,应用程序需要发送一些请求,等待回应的过程中,窗口管理器可能会发送消息。
* 因此当请求处理完毕之后,再逐一处理消息。
**/
while(!queue_empty(&global_application.message_queue))
{
union message* msg = queue_front(&global_application.message_queue);
application_handle_message(msg);
queue_pop(&global_application.message_queue);
}
return SELECTER_RETURN_TYPE_CONTINUE;
}
开发者ID:FangKuangKuang,项目名称:egui,代码行数:26,代码来源:exec.c
示例12: queue_clear
void queue_clear(orders_queue *q)
{
order_t tmp_order;
assert(q != NULL);
while(!queue_empty(q))
queue_pop(q, &tmp_order);
}
开发者ID:cbart,项目名称:sop-lab-2009,代码行数:7,代码来源:ipc_msg.c
示例13: dijkstra_distance_target
void dijkstra_distance_target(grid *distances, grid *target, const pos *targets, int count, int neighbors, cost_function_t cost_function, void *userdata){
grid_fill(distances, distances->x0, distances->y0, distances->width, distances->height, DBL_MAX);
if(target != NULL) grid_fill(target, target->x0, target->y0, target->width, target->height, -1);
queue open_set = queue_create(sizeof(pos));
for(int i = 0;i<count;++i) {
grid_set(distances, targets[i].x, targets[i].y, 0.0);
if(target != NULL) grid_set(target, targets[i].x, targets[i].y, i);
queue_push(&open_set, targets+i);
}
while(!queue_empty(&open_set)) {
pos cur = *(pos*)queue_front(&open_set);
double curdist = grid_get(distances, cur.x, cur.y);
queue_pop(&open_set);
for(int i = 0;i<neighbors;++i) {
pos neigh = {cur.x+offsets[i].x, cur.y+offsets[i].y};
if(!grid_contains(distances, neigh.x, neigh.y)) continue;
double neighdist = grid_get(distances, neigh.x, neigh.y);
double cost = cost_function(cur.x, cur.y, neigh.x, neigh.y, userdata);
if(neighdist > curdist + cost) {
grid_set(distances, neigh.x, neigh.y, curdist + cost);
if(target != NULL) grid_set(target, neigh.x, neigh.y, grid_get(target, cur.x, cur.y));
queue_push(&open_set, &neigh);
}
}
}
queue_destroy(open_set);
}
开发者ID:progschj,项目名称:TLDR,代码行数:34,代码来源:pathfinding.c
示例14: framework_release_handle
/* Release the event handle returned by framework_event_query.
* In the ASYNC model we must remove the event handle from the FIFO request
* queue. */
void framework_release_handle(naf_handle handle)
{
queue_entry* entry;
if (!handle) {
return;
}
if (queue_empty()) {
/* Why do the application try to release a handle on an empty queue? */
NABTO_LOG_FATAL(("SW error: Calling framework_release_handle on an empty queue"));
return;
}
/* Find the entry containing the handle */
entry = queue_find_entry(handle);
/* The given handle must belong to the queue */
UNABTO_ASSERT(entry);
entry->state = APPREQ_FREE;
LOG_APPREQ_WHERE("framework_release_handle", entry);
/* Remove top entry from FIFO queue - and remove all consecutive
* entries that have expired/finished in the mean time. */
while (!queue_empty()) {
if (queue_top()->state != APPREQ_FREE)
break;
queue_pop();
}
LOG_APPREQ_QUEUE();
}
开发者ID:nabto,项目名称:unabto,代码行数:34,代码来源:unabto_app_adapter.c
示例15: update_frame_v1
static void
update_frame_v1(struct accuraterip_v1 *v1,
unsigned total_pcm_frames,
unsigned start_offset,
unsigned end_offset,
unsigned value)
{
/*calculate initial checksum*/
if ((v1->index >= start_offset) && (v1->index <= end_offset)) {
v1->checksums[0] += (value * v1->index);
v1->values_sum += value;
}
/*store the first (pcm_frame_range - 1) values in initial_values*/
if ((v1->index >= start_offset) && (!queue_full(v1->initial_values))) {
queue_push(v1->initial_values, value);
}
/*store the trailing (pcm_frame_range - 1) values in final_values*/
if ((v1->index > end_offset) && (!queue_full(v1->final_values))) {
queue_push(v1->final_values, value);
}
/*calculate incremental checksums*/
if (v1->index > total_pcm_frames) {
const uint32_t initial_value = queue_pop(v1->initial_values);
const uint32_t final_value = queue_pop(v1->final_values);
const uint32_t initial_value_product =
(uint32_t)(start_offset - 1) * initial_value;
const uint32_t final_value_product =
(uint32_t)end_offset * final_value;
v1->checksums[v1->index - total_pcm_frames] =
v1->checksums[v1->index - total_pcm_frames - 1] +
final_value_product -
v1->values_sum -
initial_value_product;
v1->values_sum -= initial_value;
v1->values_sum += final_value;
}
v1->index++;
}
开发者ID:KristoforMaynard,项目名称:python-audio-tools,代码行数:47,代码来源:accuraterip.c
示例16: main
int
main ()
{
queue_t* queuePtr;
random_t* randomPtr;
long data[] = {3, 1, 4, 1, 5};
long numData = sizeof(data) / sizeof(data[0]);
long i;
randomPtr = random_alloc();
assert(randomPtr);
random_seed(randomPtr, 0);
puts("Starting tests...");
queuePtr = queue_alloc(-1);
assert(queue_isEmpty(queuePtr));
for (i = 0; i < numData; i++) {
insertData(queuePtr, &data[i]);
}
assert(!queue_isEmpty(queuePtr));
for (i = 0; i < numData; i++) {
long* dataPtr = (long*)queue_pop(queuePtr);
printf("Removing %li: ", *dataPtr);
printQueue(queuePtr);
}
assert(!queue_pop(queuePtr));
assert(queue_isEmpty(queuePtr));
puts("All tests passed.");
for (i = 0; i < numData; i++) {
insertData(queuePtr, &data[i]);
}
for (i = 0; i < numData; i++) {
printf("Shuffle %li: ", i);
queue_shuffle(queuePtr, randomPtr);
printQueue(queuePtr);
}
assert(!queue_isEmpty(queuePtr));
queue_free(queuePtr);
return 0;
}
开发者ID:nathanielherman,项目名称:sto-stamp,代码行数:47,代码来源:queue.c
示例17: queue_pop
/**
* TGDB will search it's command queue's and determine what the next command
* to deliever to GDB should be.
*
* \return
* 0 on success, -1 on error
*/
int Ctgdb::Unqueue_and_deliver_command()
{
tgdb_unqueue_and_deliver_command_tag:
/* This will redisplay the prompt when a command is run
* through the gui with data on the console.
*/
/* The out of band commands should always be run first */
if (queue_size (oob_input_queue) > 0)
{
/* These commands are always run.
* However, if an assumption is made that a misc
* prompt can never be set while in this spot.
*/
tgdb_command *item = NULL;
item = (tgdb_command *) queue_pop(oob_input_queue);
Deliver_command (item);
tgdb_command_destroy (item);
}
/* If the queue is not empty, run a command */
else if (queue_size (gdb_input_queue) > 0)
{
struct tgdb_command *item = NULL;
item = (tgdb_command *) queue_pop (gdb_input_queue);
/* If at the misc prompt, don't run the internal tgdb commands,
* In fact throw them out for now, since they are only
* 'info breakpoints' */
if (tgdb_client_can_tgdb_run_commands (tcc) == 1)
{
if (item->command_choice != TGDB_COMMAND_CONSOLE)
{
tgdb_command_destroy (item);
goto tgdb_unqueue_and_deliver_command_tag;
}
}
/* This happens when a command was skipped because the client no longer
* needs the command to be run */
if (Deliver_command(item) == -1)
goto tgdb_unqueue_and_deliver_command_tag;
tgdb_command_destroy (item);
}
return 0;
}
开发者ID:amberik,项目名称:cgdb-initial.cgdb-featured,代码行数:54,代码来源:CTgdb.cpp
示例18: queue_reset
void queue_reset(queue_t *q)
{
/* drain the queue */
while (q->first != NULL)
queue_pop(q);
queue_init(q);
}
开发者ID:designtestcode,项目名称:thin-turbo,代码行数:8,代码来源:queue.c
示例19: main
int main(){
char* a1 = "Brian";
char* b1 = "Julia";
char* c1 = "Rex";
Queue* queue = queue_constructor();
queue_push(a1, queue);
queue_push(b1, queue);
queue_push(c1, queue);
assert(strcmp((char*)queue_pop(queue), a1) == 0);
assert(strcmp((char*)queue_pop(queue), b1) == 0);
assert(strcmp((char*)queue_pop(queue), c1) == 0);
printf("test complete\n");
}
开发者ID:bcrafton,项目名称:Data-Structures,代码行数:17,代码来源:queue_test.c
示例20: sacarLlamada
nodoStack_t* sacarLlamada(imagen_proceso_t proceso)
{
void* punteroALlamada = queue_pop(proceso.segmentoDeStack);
nodoStack_t* unaLlamada;
unaLlamada = malloc(sizeof(nodoStack_t));
unaLlamada = (nodoStack_t*) punteroALlamada;
return unaLlamada;
}
开发者ID:FedericoGarou,项目名称:RepoDePrueba,代码行数:8,代码来源:ManejoDeProcesos.c
注:本文中的queue_pop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论