本文整理汇总了C++中qlen函数的典型用法代码示例。如果您正苦于以下问题:C++ qlen函数的具体用法?C++ qlen怎么用?C++ qlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pipestat
static int
pipestat(Chan *c, uchar *db, int n)
{
Pipe *p;
Dir dir;
p = c->aux;
switch(NETTYPE(c->qid.path)){
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR|0555, &dir);
break;
case Qdata0:
devdir(c, c->qid, "data", qlen(p->q[0]), eve, p->perm, &dir);
break;
case Qdata1:
devdir(c, c->qid, "data1", qlen(p->q[1]), eve, p->perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if(n < BIT16SZ)
error(Eshortstat);
return n;
}
示例2: pipegen
static int
pipegen(Chan *c, char *name, Dirtab *tab, int ntab, int i, Dir *dp)
{
int id, len;
Qid qid;
Pipe *p;
USED(name);
if(i == DEVDOTDOT){
devdir(c, c->qid, "#|", 0, eve, 0555, dp);
return 1;
}
i++; /* skip . */
if(tab==0 || i>=ntab)
return -1;
tab += i;
p = c->aux;
switch(NETTYPE(tab->qid.path)){
case Qdata0:
len = qlen(p->q[0]);
break;
case Qdata1:
len = qlen(p->q[1]);
break;
default:
len = tab->length;
break;
}
id = NETID(c->qid.path);
qid.path = NETQID(id, tab->qid.path);
qid.vers = 0;
qid.type = QTFILE;
devdir(c, qid, tab->name, len, eve, tab->perm, dp);
return 1;
}
示例3: pipegen
static int
pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
{
Qid q;
int len;
Pipe *p;
if(i == DEVDOTDOT){
devdir(c, c->qid, "#|", 0, eve, DMDIR|0555, dp);
return 1;
}
i++; /* skip . */
if(tab==0 || i>=ntab)
return -1;
tab += i;
p = c->aux;
switch((ulong)tab->qid.path){
case Qdata0:
len = qlen(p->q[0]);
break;
case Qdata1:
len = qlen(p->q[1]);
break;
default:
len = tab->length;
break;
}
mkqid(&q, NETQID(NETID(c->qid.path), tab->qid.path), 0, QTFILE);
devdir(c, q, tab->name, len, eve, p->perm, dp);
return 1;
}
示例4: regressread
static long
regressread(struct chan *c, void *va, long n, int64_t off)
{
uint64_t w, *bp;
char *a, *ea;
uintptr_t offset = off;
uint64_t pc;
int snp_ret, ret = 0;
switch((int)c->qid.path){
case Monitordirqid:
n = devdirread(c, va, n, regresstab, ARRAY_SIZE(regresstab), devgen);
break;
case Monitorctlqid:
n = readstr(off, va, n, ctlcommands);
break;
case Monitordataqid:
if (regress.monitor) {
printd("monitordataqid: regress.monitor %p len %p\n", regress.monitor, qlen(kprof.monitor));
if (qlen(regress.monitor) > 0)
n = qread(regress.monitor, va, n);
else
n = 0;
} else
error(EFAIL, "no monitor queue");
break;
default:
n = 0;
break;
}
return n;
}
示例5: pipestat
static int pipestat(struct chan *c, uint8_t * db, int n)
{
Pipe *p;
struct dir dir;
struct dirtab *tab;
int perm;
p = c->aux;
tab = p->pipedir;
switch (NETTYPE(c->qid.path)) {
case Qdir:
devdir(c, c->qid, ".", 0, eve, DMDIR | 0555, &dir);
break;
case Qdata0:
perm = tab[1].perm;
perm |= qreadable(p->q[0]) ? DMREADABLE : 0;
perm |= qwritable(p->q[0]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[1].name, qlen(p->q[0]), eve, perm, &dir);
break;
case Qdata1:
perm = tab[2].perm;
perm |= qreadable(p->q[1]) ? DMREADABLE : 0;
perm |= qwritable(p->q[1]) ? DMWRITABLE : 0;
devdir(c, c->qid, tab[2].name, qlen(p->q[1]), eve, perm, &dir);
break;
default:
panic("pipestat");
}
n = convD2M(&dir, db, n);
if (n < BIT16SZ)
error(ENODATA, ERROR_FIXME);
return n;
}
示例6: tcq_purgeq
static void
tcq_purgeq(struct tcq_if *tif, struct tcq_class *cl, u_int32_t flow,
u_int32_t *packets, u_int32_t *bytes)
{
struct ifclassq *ifq = tif->tif_ifq;
u_int32_t cnt = 0, len = 0, qlen;
IFCQ_LOCK_ASSERT_HELD(ifq);
if ((qlen = qlen(&cl->cl_q)) == 0)
goto done;
/* become regular mutex before freeing mbufs */
IFCQ_CONVERT_LOCK(ifq);
#if CLASSQ_RIO
if (q_is_rio(&cl->cl_q))
rio_purgeq(cl->cl_rio, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_RIO */
#if CLASSQ_RED
if (q_is_red(&cl->cl_q))
red_purgeq(cl->cl_red, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_RED */
#if CLASSQ_BLUE
if (q_is_blue(&cl->cl_q))
blue_purgeq(cl->cl_blue, &cl->cl_q, flow, &cnt, &len);
else
#endif /* CLASSQ_BLUE */
if (q_is_sfb(&cl->cl_q) && cl->cl_sfb != NULL)
sfb_purgeq(cl->cl_sfb, &cl->cl_q, flow, &cnt, &len);
else
_flushq_flow(&cl->cl_q, flow, &cnt, &len);
if (cnt > 0) {
VERIFY(qlen(&cl->cl_q) == (qlen - cnt));
PKTCNTR_ADD(&cl->cl_dropcnt, cnt, len);
IFCQ_DROP_ADD(ifq, cnt, len);
VERIFY(((signed)IFCQ_LEN(ifq) - cnt) >= 0);
IFCQ_LEN(ifq) -= cnt;
if (pktsched_verbose) {
log(LOG_DEBUG, "%s: %s purge qid=%d pri=%d "
"qlen=[%d,%d] cnt=%d len=%d flow=0x%x\n",
if_name(TCQIF_IFP(tif)), tcq_style(tif),
cl->cl_handle, cl->cl_pri, qlen, qlen(&cl->cl_q),
cnt, len, flow);
}
}
done:
if (packets != NULL)
*packets = cnt;
if (bytes != NULL)
*bytes = len;
}
示例7: udpstate
static int
udpstate(Conv *c, char *state, int n)
{
return snprint(state, n, "%s qin %d qout %d\n",
c->inuse ? "Open" : "Closed",
c->rq ? qlen(c->rq) : 0,
c->wq ? qlen(c->wq) : 0
);
}
示例8: codel_add_altq
int
codel_add_altq(struct ifnet *ifp, struct pf_altq *a)
{
struct codel_if *cif;
struct codel_opts *opts;
if (ifp == NULL)
return (EINVAL);
if (!ALTQ_IS_READY(&ifp->if_snd))
return (ENODEV);
opts = &a->pq_u.codel_opts;
cif = malloc(sizeof(struct codel_if), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cif == NULL)
return (ENOMEM);
cif->cif_bandwidth = a->ifbandwidth;
cif->cif_ifq = &ifp->if_snd;
cif->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO);
if (cif->cl_q == NULL) {
free(cif, M_DEVBUF);
return (ENOMEM);
}
if (a->qlimit == 0)
a->qlimit = 50; /* use default. */
qlimit(cif->cl_q) = a->qlimit;
qtype(cif->cl_q) = Q_CODEL;
qlen(cif->cl_q) = 0;
qsize(cif->cl_q) = 0;
if (opts->target == 0)
opts->target = 5;
if (opts->interval == 0)
opts->interval = 100;
cif->codel.params.target = machclk_freq * opts->target / 1000;
cif->codel.params.interval = machclk_freq * opts->interval / 1000;
cif->codel.params.ecn = opts->ecn;
cif->codel.stats.maxpacket = 256;
cif->cl_stats.qlength = qlen(cif->cl_q);
cif->cl_stats.qlimit = qlimit(cif->cl_q);
/* keep the state in pf_altq */
a->altq_disc = cif;
return (0);
}
示例9: uartsetlength
static void
uartsetlength(int i)
{
Uart *p;
if(i > 0){
p = uart[i];
if(p && p->opens && p->iq)
uartdir[1+3*i].length = qlen(p->iq);
} else for(i = 0; i < uartnuart; i++){
p = uart[i];
if(p && p->opens && p->iq)
uartdir[1+3*i].length = qlen(p->iq);
}
}
示例10: consactive
int
consactive(void)
{
if(serialoq)
return qlen(serialoq) > 0;
return 0;
}
示例11: intr_print_info
/* ---------------------------------------------------------------------- */
void
intr_print_info(void)
{
printf("sigio_blocked = %d\n", sigio_blocked);
printf("num_block_sigio = %d\n", num_block_sigio);
printf("num_unblock_sigio = %d\n", num_unblock_sigio);
printf("new_connections_on = %d\n", new_connections_on);
printf("intr_depth = %d\n", intr_depth);
#ifdef ONE_LISTENER
#ifdef TBB_QLENS
printf("qlen_listenq = %d\n", qlen_listenq(server_sd));
printf(" qlen_young = %d qlen = %d\n",
qlen_young(server_sd), qlen(server_sd));
#endif /* TBB_QLENS */
#endif /* ONE_LISTENER */
#ifdef SEND
#ifdef ARRAY_OF_BUFS
send_print_info_array();
#else
send_print_info();
#endif /* ARRAY_OF_BUFS */
#endif /* SEND */
printf("-------------------------------------------------------------\n");
}
示例12: codel_addq
int
codel_addq(struct codel *c, class_queue_t *q, struct mbuf *m)
{
struct m_tag *mtag;
uint64_t *enqueue_time;
if (qlen(q) < qlimit(q)) {
mtag = m_tag_locate(m, MTAG_CODEL, 0, NULL);
if (mtag == NULL)
mtag = m_tag_alloc(MTAG_CODEL, 0, sizeof(uint64_t),
M_NOWAIT);
if (mtag == NULL) {
m_freem(m);
return (-1);
}
enqueue_time = (uint64_t *)(mtag + 1);
*enqueue_time = read_machclk();
m_tag_prepend(m, mtag);
_addq(q, m);
return (0);
}
c->drop_overlimit++;
m_freem(m);
return (-1);
}
示例13: ethertxpkt
int
ethertxpkt(int ctlrno, Etherpkt *pkt, int len, int)
{
Ctlr *ctlr;
Block *b;
int s;
if((ctlr = attach(ctlrno)) == 0)
return 0;
if(qlen(ctlr->oq) > 16*1024){
print("ether%d: tx queue full\n", ctlrno);
return 0;
}
b = iallocb(sizeof(Etherpkt));
memmove(b->wp, pkt, len);
memmove(((Etherpkt*)b->wp)->s, ctlr->card.ea, Eaddrlen);
b->wp += len;
qbwrite(ctlr->oq, b);
s = splhi();
(*ctlr->card.transmit)(ctlr);
splx(s);
return 1;
}
示例14: rx_fill
static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
{
struct usb_request *req;
unsigned long flags;
int req_cnt = 0;
/* fill unused rxq slots with some skb */
spin_lock_irqsave(&dev->req_lock, flags);
while (!list_empty(&dev->rx_reqs)) {
/* break the nexus of continuous completion and re-submission*/
if (++req_cnt > qlen(dev->gadget))
break;
req = container_of(dev->rx_reqs.next,
struct usb_request, list);
list_del_init(&req->list);
spin_unlock_irqrestore(&dev->req_lock, flags);
if (rx_submit(dev, req, gfp_flags) < 0) {
spin_lock_irqsave(&dev->req_lock, flags);
list_add(&req->list, &dev->rx_reqs);
spin_unlock_irqrestore(&dev->req_lock, flags);
defer_kevent(dev, WORK_RX_MEMORY);
return;
}
spin_lock_irqsave(&dev->req_lock, flags);
}
spin_unlock_irqrestore(&dev->req_lock, flags);
}
示例15: get_class_stats
/* copy the stats info in rm_class to class_states_t */
static void
get_class_stats(class_stats_t *statsp, struct rm_class *cl)
{
statsp->xmit_cnt = cl->stats_.xmit_cnt;
statsp->drop_cnt = cl->stats_.drop_cnt;
statsp->over = cl->stats_.over;
statsp->borrows = cl->stats_.borrows;
statsp->overactions = cl->stats_.overactions;
statsp->delays = cl->stats_.delays;
statsp->depth = cl->depth_;
statsp->priority = cl->pri_;
statsp->maxidle = cl->maxidle_;
statsp->minidle = cl->minidle_;
statsp->offtime = cl->offtime_;
statsp->qmax = qlimit(cl->q_);
statsp->ns_per_byte = cl->ns_per_byte_;
statsp->wrr_allot = cl->w_allotment_;
statsp->qcnt = qlen(cl->q_);
statsp->avgidle = cl->avgidle_;
statsp->qtype = qtype(cl->q_);
#ifdef ALTQ_RED
if (q_is_red(cl->q_))
red_getstats(cl->red_, &statsp->red[0]);
#endif
#ifdef ALTQ_RIO
if (q_is_rio(cl->q_))
rio_getstats((rio_t *)cl->red_, &statsp->red[0]);
#endif
}