• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ queue_push函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: rsys_render_req

int rsys_render_req(struct rsys* rsys, rsys_req_t* req)
{
    ocn_spin_lock(&rsys->render_reqs_lock);
    queue_push(&rsys->render_reqs, req);
    ocn_spin_unlock(&rsys->render_reqs_lock);
    return OCN_OK;
}
开发者ID:onixion,项目名称:pandarus,代码行数:7,代码来源:rsys.c


示例2: thread_pool_add_task_to_queue

void thread_pool_add_task_to_queue(pool_t *pool, task_t task)
{
    pthread_mutex_lock(&pool->mutex_);
    queue_push(&pool->queue_, task);
    pthread_cond_signal(&pool->cond_);
    pthread_mutex_unlock(&pool->mutex_);
}
开发者ID:lvchao0428,项目名称:ultrapp,代码行数:7,代码来源:thread_pool.c


示例3: stop_workers

static void stop_workers(void)
{
	const char stop_code[1] = { '\0' };
	int i, stop_attempts;

	if (!workers)
		return;

	for (i = 0; i < worker_count; i++) {
		stop_attempts = 0xffff;
		if (workers[i].q) {
			while (!queue_push(workers[i].q, stop_code)) {
				if (--stop_attempts < 0) {
					tst_brk(TBROK,
						"Worker %d is stalled",
						workers[i].pid);
					break;
				}
			}
		}
	}

	for (i = 0; i < worker_count; i++) {
		if (workers[i].q) {
			queue_destroy(workers[i].q, 0);
			workers[i].q = 0;
		}
	}
}
开发者ID:sathnaga,项目名称:ltp,代码行数:29,代码来源:read_all.c


示例4: connection_close

void connection_close(connection_t *c)
{
  ev_io_stop(c->loop, &c->read_watcher);
  ev_io_stop(c->loop, &c->write_watcher);
  ev_timer_stop(c->loop, &c->timeout_watcher);

  close(c->fd);
  shutdown(c->fd, SHUT_RDWR);
  
  buffer_reset(&c->read_buffer);
  buffer_reset(&c->write_buffer);
  
  /* tell Ruby GC vars are not used anymore */
  rb_gc_unregister_address(&c->env);
  rb_gc_unregister_address(&c->input);
  
  /* kill the thread if still running */
  if (c->thread.active) {
    c->backend->thread_count--;
    rb_thread_kill(c->thread.obj);
  }
  
  /* put back in the queue of unused connections */
  queue_push(&c->backend->connections, c);
}
开发者ID:designtestcode,项目名称:thin-turbo,代码行数:25,代码来源:connection.c


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


示例6: websocket_send

// sets errno on error
int websocket_send(Socket *socket, void *buffer, int length) {
	Websocket *websocket = (Websocket *)socket;
	WebsocketQueuedData *queued_data;

	if (websocket->state == WEBSOCKET_STATE_HANDSHAKE_DONE ||
	    websocket->state == WEBSOCKET_STATE_HEADER_DONE) {
		return websocket_send_frame(websocket, buffer, length);
	}

	// initial handshake not finished yet
	if (length > 0) {
		queued_data = queue_push(&websocket->send_queue);

		if (queued_data == NULL) {
			return -1;
		}

		queued_data->buffer = malloc(length);
		queued_data->length = length;

		if (queued_data->buffer == NULL) {
			errno = ENOMEM;

			return -1;
		}

		memcpy(queued_data->buffer, buffer, length);
	}

	return length;
}
开发者ID:vszurma,项目名称:brickd,代码行数:32,代码来源:websocket.c


示例7: destruct_esqlite_connection

static void 
destruct_esqlite_connection(ErlNifEnv *env, void *arg)
{
    esqlite_connection *db = (esqlite_connection *) arg;
    esqlite_command *cmd = command_create();
  
    /* Send the stop command 
     */
    cmd->type = cmd_stop;
    queue_push(db->commands, cmd);
    queue_send(db->commands, cmd);
     
    /* Wait for the thread to finish 
     */
    enif_thread_join(db->tid, NULL);
    enif_thread_opts_destroy(db->opts);
     
    /* The thread has finished... now remove the command queue, and close
     * the datbase (if it was still open).
     */
    queue_destroy(db->commands);

    if(db->db)
	   sqlite3_close(db->db);
}
开发者ID:chinnurtb,项目名称:esqlite,代码行数:25,代码来源:esqlite3_nif.c


示例8: actualizacionCriteriosNivel

int actualizacionCriteriosNivel(int iSocketConexion, char* sPayload, tNivel* pNivel, tPersonaje *pPersonajeActual) {
	tInfoNivel* pInfoNivel;
	pInfoNivel = deserializarInfoNivel(sPayload);
	free(sPayload);

	log_debug(logger, "<<< Recibe actualizacion de criterios del nivel");

	pNivel->quantum = pInfoNivel->quantum;
	pNivel->delay   = pInfoNivel->delay;

	if (pNivel->algoritmo != pInfoNivel->algoritmo) {
		pNivel->algoritmo = pInfoNivel->algoritmo;

		if (!nivelVacio(pNivel)) {

			if(pInfoNivel->algoritmo==SRDF){
				if (pPersonajeActual != NULL) {
					pPersonajeActual->quantumUsado = 0;
					queue_push(pNivel->cListos, pPersonajeActual);
				}

				bool _menorRemainingDistance(tPersonaje *unPersonaje, tPersonaje *otroPersonaje) {
					return (unPersonaje->remainingDistance < otroPersonaje->remainingDistance );
				}
				list_sort(pNivel->cListos->elements, (void *)_menorRemainingDistance);
			}
		}
	}
开发者ID:MaximilianoFelice,项目名称:tp-sistemas-operativos,代码行数:28,代码来源:plataforma.c


示例9: pool_add_pos_literals_complex_dep

void
pool_add_pos_literals_complex_dep(Pool *pool, Id dep, Queue *q, Map *m, int neg)
{
  while (ISRELDEP(dep))
    {
      Reldep *rd = GETRELDEP(pool, dep);
      if (rd->flags != REL_AND && rd->flags != REL_OR && rd->flags != REL_COND)
	break;
      pool_add_pos_literals_complex_dep(pool, rd->name, q, m, neg);
      dep = rd->evr;
      if (rd->flags == REL_COND)
	{
	  neg = !neg;
	  if (ISRELDEP(dep))
	    {
	      Reldep *rd2 = GETRELDEP(pool, rd->evr);
	      if (rd2->flags == REL_ELSE)
		{
	          pool_add_pos_literals_complex_dep(pool, rd2->evr, q, m, !neg);
		  dep = rd2->name;
		}
	    }
	}
    }
  if (!neg)
    {
      Id p, pp;
      FOR_PROVIDES(p, pp, dep)
	if (!MAPTST(m, p))
	  queue_push(q, p);
    }
开发者ID:iamcourtney,项目名称:libsolv,代码行数:31,代码来源:cplxdeps.c


示例10: pipeline_create

void pipeline_create(
        pipeline_data_create_t create,
        pipeline_data_free_t destroy,
        pipeline_split_t split,
        pipeline_process_t process,
        size_t max_procs) {
    gPLFreer = destroy;
    gPLSplit = split;
    gPLProcess = process;

    gPipelineStartQ = queue_new(pipeline_qfree);
    gPipelineSplitQ = queue_new(pipeline_qfree);
    gPipelineMergeQ = queue_new(pipeline_qfree);

    gPLSplitSeq = 0;
    gPLMergeSeq = 0;
    gPLMergedItems = NULL;

    gPLProcessCount = num_threads(max_procs);
    gPLProcessThreads = malloc(gPLProcessCount * sizeof(pthread_t));
    for (size_t i = 0; i < (int)(gPLProcessCount * 2 + 3); ++i) {
        // create blocks, including a margin of error
        pipeline_item_t *item = malloc(sizeof(pipeline_item_t));
        item->data = create();
        // seq and next are garbage
        queue_push(gPipelineStartQ, PIPELINE_ITEM, item);
    }
    for (size_t i = 0; i < gPLProcessCount; ++i) {
        if (pthread_create(&gPLProcessThreads[i], NULL,
                &pipeline_thread_process, (void*)(uintptr_t)i))
            die("Error creating encode thread");
    }
    if (pthread_create(&gPLSplitThread, NULL, &pipeline_thread_split, NULL))
        die("Error creating read thread");
}
开发者ID:hornos,项目名称:pixz,代码行数:35,代码来源:common.c


示例11: sacarDeCola

int sacarDeCola(t_queue *cola,listaPersonajesStruct *unPersonaje,char info , t_log *log, pthread_mutex_t *semColas)
{
	t_queue *colaAuxiliar;
	int loEncontre = 0;
	listaPersonajesStruct *personajeEnCola;
	colaAuxiliar = queue_create();

	pthread_mutex_lock(semColas);
	while(!queue_is_empty(cola))
	{
		personajeEnCola = queue_pop(cola);
		if(personajeEnCola->nombre != unPersonaje->nombre)
		{
			queue_push(colaAuxiliar, (void *) personajeEnCola);
		}
		else
		{
			if(info == 'L')
				log_info(log,"Borre de Listos a %s",unPersonaje->nombre);
			if(info == 'B')
				log_info(log,"Borre de Bloqueados a %s",unPersonaje->nombre);
			loEncontre = 1;
		}
	}

	queue_copy(cola,colaAuxiliar);
	pthread_mutex_unlock(semColas);
	queue_destroy(colaAuxiliar);

	return loEncontre;
}
开发者ID:nikopfleger,项目名称:SISOPTP1C2013,代码行数:31,代码来源:funcionesPlataforma.c


示例12: dummycomb

void* dummycomb(void *arg){
	arg = arg;
	queue_pop(&queue, &pri);
	//sleep(1);
	queue_push(&queue, pri);
	return NULL;
}
开发者ID:agmathiesen,项目名称:OSM,代码行数:7,代码来源:test.c


示例13: queue_get_item

static void *producer(void *arg)
{
	threadinf *inf = (threadinf*)arg;
	char *op;
	int i;
	long long int me = (long long int)pthread_self();

	for (i = 0; i < ITERATIONS; i++)
	{
		// printf("PULL! %lld\n",me);
		item *it;
		qitem *qi = queue_get_item(inf->q);
		if (qi->cmd == NULL)
			qi->cmd = malloc(sizeof(item));
		it = (item*)qi->cmd;
		it->n = i;
		it->thread = inf->thread;
		queue_push(inf->q,qi);
		// if (tries > 10)
			// printf("%lld, i=%d, tries=%d, index=%d\n",me, i, tries, index);

		// if ((i % 10000) == 0)
		// 	printf("pthr=%lld, i=%d\n",me, i);
	}

	return NULL;
}
开发者ID:ekkotron,项目名称:actordb_driver,代码行数:27,代码来源:lfqueue.c


示例14: ReqThreads

//Read input file function
void* ReqThreads(void* Inputfile) 
{
	char* hostname;
	hostname = malloc(SBUFSIZE*sizeof(char)); //use malloc to allocate memory
	FILE* fp = fopen(Inputfile, "r");
	
	//Read File and Process, list of text, url hostnames
	while (fscanf(fp, INPUTFS, hostname) > 0) {
		
		//If queue is full, wait and sleep
		while(queue_is_full(requesterQ)) { //busy wait
			usleep((rand()% 100)+1);
			continue;   
			} 
		
			pthread_mutex_lock(&Q_lock); //lock so only one thread can access queue
			queue_push(requesterQ, hostname); //push the hostname onto the queue
			pthread_mutex_unlock(&Q_lock); //unlock when done pushing an item

			hostname = malloc(SBUFSIZE*sizeof(char));
	}
	free(hostname); //free the space allocated with malloc
	fclose(fp); //close input file when done
	return 0;
}
开发者ID:entzel,项目名称:Dnslookup,代码行数:26,代码来源:multilookup.c


示例15: schedule_download

/**
 * @brief schedule_download Push file in the first priority download queue.
 *
 * @note Set errno to ENOMEM since this is the only kind of error
 *       within open-calls family that reflects system error.
 *
 * @param[in] fd File descriptor to calculate "proc-path" to be pushed to queue.
 *
 * @return  0: file has been successfully pushed to queue;
 *         -1: error happen during opening of shared memory object containing
 *             queue or queue push operation failed.
 */
int schedule_download( int fd ) {
        /* open shared memory object with queue if not already */
        pthread_once( &once_control, init_vars_once );
        if ( queue == NULL ) {
                /* error happen during mapping of queue from shared memory */
                 errno = ENOMEM;
                return -1;
        }

        char path[PROC_PID_FD_FD_PATH_MAX_LEN];
        snprintf(path,
                 PROC_PID_FD_FD_PATH_MAX_LEN,
                 PROC_PID_FD_FD_PATH_TEMPLATE,
                 (unsigned long long int)pid,
                 (unsigned long long int)fd);

        if ( queue_push( queue, path, PROC_PID_FD_FD_PATH_MAX_LEN ) == -1 ) {
                /* this is very unlikely situation with blocking
                   push operation */
                errno = ENOMEM;
                return -1;
        }

        return 0;
}
开发者ID:aoool,项目名称:tiering,代码行数:37,代码来源:syms.c


示例16: push_command

static ERL_NIF_TERM
push_command(ErlNifEnv *env, esqlite_connection *conn, esqlite_command *cmd) {
    if(!queue_push(conn->commands, cmd)) 
        return make_error_tuple(env, "command_push_failed");
  
    return make_atom(env, "ok");
}
开发者ID:chinnurtb,项目名称:esqlite,代码行数:7,代码来源:esqlite3_nif.c


示例17: seleccionarPorRoundRobin

void seleccionarPorRoundRobin(datos_planificador_t *datosPlan) {
	if (datosPlan->personajeEnMovimiento == NULL ) {
		datosPlan->quantumCorriente = datosPlan->quatum;
		pthread_mutex_lock(datosPlan->mutexColas);
		datosPlan->personajeEnMovimiento = queue_pop(
				datosPlan->personajesListos);
		pthread_mutex_unlock(datosPlan->mutexColas);
		log_info(logFile, "Personaje %c seleccionado por RR.",
				datosPlan->personajeEnMovimiento->simbolo);
	} else if (datosPlan->quantumCorriente == 0) {
		log_info(logFile, "Personaje %c finalizo quantum.",
				datosPlan->personajeEnMovimiento->simbolo);
		pthread_mutex_lock(datosPlan->mutexColas);
		queue_push(datosPlan->personajesListos,
				datosPlan->personajeEnMovimiento);
		datosPlan->quantumCorriente = datosPlan->quatum;
		datosPlan->personajeEnMovimiento = queue_pop(
				datosPlan->personajesListos);
		pthread_mutex_unlock(datosPlan->mutexColas);
		log_info(logFile, "Personaje %c seleccionado por RR.",
				datosPlan->personajeEnMovimiento->simbolo);
	}

	enviarTurnoConcedido(datosPlan->personajeEnMovimiento);
	atenderPedidoPersonaje(datosPlan, datosPlan->personajeEnMovimiento->sockfd);
}
开发者ID:julietaf,项目名称:repo20132C,代码行数:26,代码来源:Planificador.c


示例18: queue_put_event

void queue_put_event(Queue *queue, Event event)
{
  queue_push(queue, event);
  if (!mainloop()->running) {
    uv_prepare_start(&mainloop()->event_prepare, prepare_events);
  }
}
开发者ID:jollywho,项目名称:nav,代码行数:7,代码来源:event.c


示例19: service_send

int service_send(uint32_t handle, struct message *m) {
	struct service *s = service_grab(handle);
	if (!s) return -1;
	queue_push(s->queue, m);
	service_release(handle);
	return m->session;
}
开发者ID:zhoukk,项目名称:service,代码行数:7,代码来源:service.c


示例20: pool_free

void pool_free(void *data)
{
	struct slot *s = (struct slot *) (((char *) data) - headerlen);
	debug("FREE", "freeing slot %d from pool %d", s->index, s->size);
	struct pool *p = get_pool(s->size);
	queue_push(p->freed, (void *) s);
}
开发者ID:robbassi,项目名称:memory-pool,代码行数:7,代码来源:pool.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ queue_size函数代码示例发布时间:2022-05-30
下一篇:
C++ queue_pop函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap