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


C++ STAILQ_REMOVE_HEAD函数代码示例

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


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

示例1: upthread_cond_signal

int upthread_cond_signal(upthread_cond_t *c)
{
	if(c == NULL)
		return EINVAL;

	mcs_lock_qnode_t qnode = {0};
	mcs_pdr_lock(&c->lock, &qnode);
	upthread_t upthread = STAILQ_FIRST(&c->queue);
	if(upthread)
		STAILQ_REMOVE_HEAD(&c->queue, next);
	mcs_pdr_unlock(&c->lock, &qnode);

	if (upthread != NULL) {
		uthread_runnable((struct uthread*)upthread);
	}
	return 0;
}
开发者ID:klueska,项目名称:upthread,代码行数:17,代码来源:condvar.c

示例2: ntb_list_rm

static struct ntb_queue_entry *
ntb_list_rm(struct mtx *lock, struct ntb_queue_list *list)
{
	struct ntb_queue_entry *entry;

	mtx_lock_spin(lock);
	if (STAILQ_EMPTY(list)) {
		entry = NULL;
		goto out;
	}
	entry = STAILQ_FIRST(list);
	STAILQ_REMOVE_HEAD(list, entry);
out:
	mtx_unlock_spin(lock);

	return (entry);
}
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:17,代码来源:if_ntb.c

示例3: while

static void *server_worker(void *arg)
{
	struct request *req;

	while (1) {
		pthread_mutex_lock(&req_mutex);
		while (STAILQ_EMPTY(&requestq)) {
			pthread_cond_wait(&req_cond, &req_mutex);
		}
		req = STAILQ_FIRST(&requestq);
		STAILQ_REMOVE_HEAD(&requestq, link);
		pthread_mutex_unlock(&req_mutex);
		server_process_request(req);
	}

	return NULL;
}
开发者ID:jigarvora,项目名称:webclient_webserver,代码行数:17,代码来源:webserver.c

示例4: ble_ll_flush_pkt_queue

/**
 * Flush a link layer packet queue.
 *
 * @param pktq
 */
static void
ble_ll_flush_pkt_queue(struct ble_ll_pkt_q *pktq)
{
    struct os_mbuf_pkthdr *pkthdr;
    struct os_mbuf *om;

    /* FLush all packets from Link layer queues */
    while (STAILQ_FIRST(pktq)) {
        /* Get mbuf pointer from packet header pointer */
        pkthdr = STAILQ_FIRST(pktq);
        om = OS_MBUF_PKTHDR_TO_MBUF(pkthdr);

        /* Remove from queue and free the mbuf */
        STAILQ_REMOVE_HEAD(pktq, omp_next);
        os_mbuf_free_chain(om);
    }
}
开发者ID:apache,项目名称:incubator-mynewt-core,代码行数:22,代码来源:ble_ll.c

示例5: _gdp_event_new

static EP_STAT
_gdp_event_new(gdp_event_t **gevp)
{
	gdp_event_t *gev = NULL;

	ep_thr_mutex_lock(&FreeListMutex);
	if ((gev = STAILQ_FIRST(&FreeList)) != NULL)
		STAILQ_REMOVE_HEAD(&FreeList, queue);
	ep_thr_mutex_unlock(&FreeListMutex);
	if (gev == NULL)
	{
		gev = ep_mem_zalloc(sizeof *gev);
	}
	*gevp = gev;
	ep_dbg_cprintf(Dbg, 48, "_gdp_event_new => %p\n", gev);
	return EP_STAT_OK;
}
开发者ID:jugador87,项目名称:gdp,代码行数:17,代码来源:gdp_event.c

示例6: EnterCriticalSection

static INLINE LOG_ENTRY *GetQueueEntry(VOID)
{
    LOG_ENTRY *entry;

    EnterCriticalSection(&logLock);

    // Pop the first entry off the queue
    if (!STAILQ_EMPTY(&logQueue)) {
        entry = STAILQ_FIRST(&logQueue);
        STAILQ_REMOVE_HEAD(&logQueue, link);
    } else {
        entry = NULL;
    }

    LeaveCriticalSection(&logLock);
    return entry;
}
开发者ID:MalaGaM,项目名称:nxscripts,代码行数:17,代码来源:logfile.c

示例7: rte_log_add_in_history

int
rte_log_add_in_history(const char *buf, size_t size)
{
	struct log_history *hist_buf = NULL;
	static const unsigned hist_buf_size = LOG_ELT_SIZE - sizeof(*hist_buf);
	void *obj;

	if (history_enabled == 0)
		return 0;

	rte_spinlock_lock(&log_list_lock);

	/* get a buffer for adding in history */
	if (log_history_size > RTE_LOG_HISTORY) {
		hist_buf = STAILQ_FIRST(&log_history);
		STAILQ_REMOVE_HEAD(&log_history, next);
	}
	else {
		if (rte_mempool_mc_get(log_history_mp, &obj) < 0)
			obj = NULL;
		hist_buf = obj;
	}

	/* no buffer */
	if (hist_buf == NULL) {
		rte_spinlock_unlock(&log_list_lock);
		return -ENOBUFS;
	}

	/* not enough room for msg, buffer go back in mempool */
	if (size >= hist_buf_size) {
		rte_mempool_mp_put(log_history_mp, hist_buf);
		rte_spinlock_unlock(&log_list_lock);
		return -ENOBUFS;
	}

	/* add in history */
	memcpy(hist_buf->buf, buf, size);
	hist_buf->buf[size] = hist_buf->buf[hist_buf_size-1] = '\0';
	hist_buf->size = size;
	STAILQ_INSERT_TAIL(&log_history, hist_buf, next);
	log_history_size++;
	rte_spinlock_unlock(&log_list_lock);

	return 0;
}
开发者ID:RIFTIO,项目名称:RIFT.ware,代码行数:46,代码来源:eal_common_log.c

示例8: ida_start

/*
 * This routine will be called from ida_intr in order to queue up more
 * I/O, meaning that we may be in an interrupt context.  Hence, we should
 * not muck around with spl() in this routine.
 */
static void
ida_start(struct ida_softc *ida)
{
	struct ida_qcb *qcb;

	while ((qcb = STAILQ_FIRST(&ida->qcb_queue)) != NULL) {
		if (ida->cmd.fifo_full(ida))
			break;
		STAILQ_REMOVE_HEAD(&ida->qcb_queue, link.stqe);
		/*
		 * XXX
		 * place the qcb on an active list and set a timeout?
		 */
		qcb->state = QCB_ACTIVE;
		ida->cmd.submit(ida, qcb);
	}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:22,代码来源:ida.c

示例9: buf_time_append

void buf_time_append(struct context *ctx, struct buf_time_tqh *queue,
        struct mbuf *buf, int64_t read_time)
{
    struct buf_time *t;
    if (!STAILQ_EMPTY(&ctx->free_buf_timeq)) {
        t = STAILQ_FIRST(&ctx->free_buf_timeq);
        STAILQ_REMOVE_HEAD(&ctx->free_buf_timeq, next);
        ctx->mstats.free_buf_times--;
    } else {
        t = cv_calloc(1, sizeof(struct buf_time));
    }
    t->ctx = ctx;
    t->buf = buf;
    t->pos = buf->last;
    t->read_time = read_time;
    STAILQ_INSERT_TAIL(queue, t, next);
    ctx->mstats.buf_times++;
}
开发者ID:BBGIP,项目名称:corvus,代码行数:18,代码来源:mbuf.c

示例10: enum_pairs_free

void
enum_pairs_free(struct enum_pairs *headp)
{
	struct enum_pair *e;

	if (headp == NULL)
		return;

	while ((e = STAILQ_FIRST(headp)) != NULL) {
		STAILQ_REMOVE_HEAD(headp, link);

		if (e->enum_str)
			free(e->enum_str);
		free(e);
	}

	free(headp);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:18,代码来源:bsnmpmap.c

示例11: threads_wait

/* Wait for a thread in the set to exit, and return its data pointer. */
void *
threads_wait(struct threads *tds)
{
	struct thread *td;
	void *data;

	threads_lock(tds);
	while (STAILQ_EMPTY(&tds->threads_dead)) {
		assert(!LIST_EMPTY(&tds->threads_running));
		pthread_cond_wait(&tds->thread_exited, &tds->threads_mtx);
	}
	td = STAILQ_FIRST(&tds->threads_dead);
	STAILQ_REMOVE_HEAD(&tds->threads_dead, deadlist);
	threads_unlock(tds);
	data = td->data;
	free(td);
	return (data);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:19,代码来源:threads.c

示例12: queue_destroy

int
queue_destroy(struct Queue *q)
{
	struct QueueEntry *qi;

	assert(STAILQ_EMPTY(&q->queue));
	while (!STAILQ_EMPTY(&q->pool))
	{
		qi = STAILQ_FIRST(&q->pool);
		STAILQ_REMOVE_HEAD(&q->pool, entries);
		q->pool_length--;
		free(qi);
	}
	AZ(pthread_cond_destroy(&q->cv));
	AZ(pthread_mutex_destroy(&q->mutex));
	free(q);
	return 1;
}
开发者ID:c-ong,项目名称:libshcodecs,代码行数:18,代码来源:thrqueue.c

示例13: otus_get_cmdbuf

struct otus_cmd *
otus_get_cmdbuf(struct otus_softc *sc)
{
	struct otus_cmd *uc;

	OTUS_LOCK_ASSERT(sc);

	uc = STAILQ_FIRST(&sc->sc_cmd_inactive);
	if (uc != NULL) {
		STAILQ_REMOVE_HEAD(&sc->sc_cmd_inactive, next);
		OTUS_STAT_DEC(sc, st_cmd_inactive);
	} else
		uc = NULL;
	if (uc == NULL)
		DPRINTF(sc, OTUS_DEBUG_CMDS, "%s: %s\n", __func__,
		    "out of command xmit buffers");
	return (uc);
}
开发者ID:erikarn,项目名称:otus,代码行数:18,代码来源:if_otus_cmd.c

示例14: fini_fs_tbl

/**
 * Get rid of all data
 */
void
fini_fs_tbl(void)
{
	struct fs_map_entry *n1;

     	while ((n1 = STAILQ_FIRST(&fs_map)) != NULL) {
		STAILQ_REMOVE_HEAD(&fs_map, link);
		if (n1->entry != NULL) {
			TAILQ_REMOVE(&fs_tbl, n1->entry, link);
			free(n1->entry->mountPoint);
			free(n1->entry->remoteMountPoint);
			free(n1->entry);
		}
		free(n1->a_name);
		free(n1);
     	}
	assert(TAILQ_EMPTY(&fs_tbl));
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:21,代码来源:hostres_fs_tbl.c

示例15: ui_msg_flush

int ui_msg_flush(int max)
{
   int i = 0;
   int old = 0;
   struct ui_message *msg;
  

   /* sanity checks */
   if (!GBL_UI->initialized)
      return 0;
     
   if (STAILQ_EMPTY(&messages_queue))
	return 0; 

   // don't allow the thread to cancel while holding the ui mutex
   pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);

   /* the queue is updated by other threads */
   UI_MSG_LOCK;
   

   while ( (msg = STAILQ_FIRST(&messages_queue)) != NULL) {

      /* diplay the message */
      GBL_UI->msg(msg->message);

      STAILQ_REMOVE_HEAD(&messages_queue, msg, next);
      /* free the message */
      SAFE_FREE(msg->message);
      SAFE_FREE(msg);
      
      /* do not display more then 'max' messages */
      if (++i == max)
         break;
   }
   
   UI_MSG_UNLOCK;

   pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);

   /* returns the number of displayed messages */
   return i;
   
}
开发者ID:tux-mind,项目名称:platform_external_ettercap,代码行数:44,代码来源:ec_ui.c


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