本文整理汇总了C++中dlist_insert_tail函数的典型用法代码示例。如果您正苦于以下问题:C++ dlist_insert_tail函数的具体用法?C++ dlist_insert_tail怎么用?C++ dlist_insert_tail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dlist_insert_tail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fi_ibv_add_rai
static int fi_ibv_add_rai(struct dlist_entry *verbs_devs, struct rdma_cm_id *id,
struct rdma_addrinfo *rai)
{
struct verbs_dev_info *dev;
struct verbs_addr *addr;
const char *dev_name;
if (!(addr = malloc(sizeof(*addr))))
return -FI_ENOMEM;
addr->rai = rai;
dev_name = ibv_get_device_name(id->verbs->device);
dlist_foreach_container(verbs_devs, struct verbs_dev_info, dev, entry)
if (!strcmp(dev_name, dev->name))
goto add_rai;
if (!(dev = malloc(sizeof(*dev))))
goto err1;
if (!(dev->name = strdup(dev_name)))
goto err2;
dlist_init(&dev->addrs);
dlist_insert_tail(&dev->entry, verbs_devs);
add_rai:
dlist_insert_tail(&addr->entry, &dev->addrs);
return 0;
err2:
free(dev);
err1:
free(addr);
return -FI_ENOMEM;
}
示例2: load_config
static inline void load_config(void) {
/* FIXME */
if ((cfg = config_load("/etc/xcb/pd.conf"))) {
char *cat = category_browse(cfg, NULL);
while (cat) {
if (!strcasecmp(cat, "pair")) {
struct variable *var = variable_browse(cfg, cat);
struct cpl *cpl = NULL;
while (var) {
if (!strcasecmp(var->name, "contract1")) {
if (!strcasecmp(var->value, ""))
break;
if (cpl == NULL) {
if (NEW(cpl) == NULL)
break;
cpl->contract2 = NULL;
cpl->price1 = cpl->price2 = cpl->prevpd = -1.0;
pthread_spin_init(&cpl->lock, 0);
}
cpl->contract1 = var->value;
} else if (!strcasecmp(var->name, "contract2")) {
if (!strcasecmp(var->value, ""))
break;
if (cpl == NULL) {
if (NEW(cpl) == NULL)
break;
cpl->contract1 = NULL;
cpl->price1 = cpl->price2 = cpl->prevpd = -1.0;
pthread_spin_init(&cpl->lock, 0);
}
cpl->contract2 = var->value;
} else
xcb_log(XCB_LOG_WARNING, "Unknown variable '%s' in "
"category '%s' of pd.conf", var->name, cat);
var = var->next;
}
if (cpl && cpl->contract1 && cpl->contract2) {
dlist_t dlist;
if ((dlist = table_get_value(contracts, cpl->contract1)) == NULL) {
dlist = dlist_new(NULL, NULL);
table_insert(contracts, cpl->contract1, dlist);
}
dlist_insert_tail(dlist, cpl);
if ((dlist = table_get_value(contracts, cpl->contract2)) == NULL) {
dlist = dlist_new(NULL, NULL);
table_insert(contracts, cpl->contract2, dlist);
}
dlist_insert_tail(dlist, cpl);
dlist_insert_tail(pairs, cpl);
} else if (cpl)
FREE(cpl);
}
cat = category_browse(cfg, cat);
}
}
}
示例3: sall_command
/* FIXME */
void sall_command(client c) {
dstr res = get_indices();
dstr *fields = NULL;
int nfield = 0, i;
RTRIM(res);
fields = dstr_split_len(res, dstr_length(res), ",", 1, &nfield);
for (i = 1; i < nfield; ++i) {
dstr pkey = dstr_new(fields[i]);
dstr skey = dstr_new(pkey);
dlist_t dlist;
struct kvd *kvd;
table_rwlock_wrlock(subscribers);
if ((dlist = table_get_value(subscribers, pkey)) == NULL) {
if (NEW(kvd)) {
kvd->key = skey;
kvd->u.dlist = dlist_new(NULL, NULL);
dlist_insert_tail(kvd->u.dlist, c);
dlist = dlist_new(cmpkvd, kdfree);
dlist_insert_sort(dlist, kvd);
table_insert(subscribers, pkey, dlist);
} else {
add_reply_error(c, "error allocating memory for kvd\r\n");
dstr_free(skey);
dstr_free(pkey);
}
} else {
if (NEW(kvd)) {
dlist_node_t node;
kvd->key = skey;
kvd->u.dlist = dlist_new(NULL, NULL);
if ((node = dlist_find(dlist, kvd)) == NULL) {
dlist_insert_tail(kvd->u.dlist, c);
dlist_insert_sort(dlist, kvd);
} else {
kdfree(kvd);
kvd = (struct kvd *)dlist_node_value(node);
if (dlist_find(kvd->u.dlist, c) == NULL)
dlist_insert_tail(kvd->u.dlist, c);
}
} else {
add_reply_error(c, "error allocating memory for kvd\r\n");
dstr_free(skey);
}
dstr_free(pkey);
}
table_rwlock_unlock(subscribers);
}
dstr_free(res);
//--------------------------------------------------------------------------------------------------------------------
// FIXME
//--------------------------------------------------------------------------------------------------------------------
}
示例4: sock_set_sockopts
static struct sock_conn *sock_conn_map_insert(struct sock_ep *ep,
struct sockaddr_in *addr, int conn_fd,
int addr_published)
{
int index;
struct sock_conn_map *map = &ep->cmap;
if (map->size == map->used) {
if (sock_conn_map_increase(map, map->size * 2))
return 0;
}
index = map->used;
map->used++;
map->table[index].addr = *addr;
map->table[index].sock_fd = conn_fd;
map->table[index].ep = ep;
sock_set_sockopts(conn_fd);
fastlock_acquire(&ep->lock);
dlist_insert_tail(&map->table[index].ep_entry, &ep->conn_list);
fastlock_release(&ep->lock);
if (idm_set(&ep->conn_idm, conn_fd, &map->table[index]) < 0)
SOCK_LOG_ERROR("idm_set failed\n");
if (sock_epoll_add(&map->epoll_set, conn_fd))
SOCK_LOG_ERROR("failed to add to epoll set: %d\n", conn_fd);
map->table[index].address_published = addr_published;
sock_pe_poll_add(ep->domain->pe, conn_fd);
return &map->table[index];
}
示例5: SOCK_LOG_ERROR
struct sock_rx_entry *sock_rx_new_buffered_entry(struct sock_rx_ctx *rx_ctx,
size_t len)
{
struct sock_rx_entry *rx_entry;
if (rx_ctx->buffered_len + len >= rx_ctx->attr.total_buffered_recv) {
SOCK_LOG_ERROR("Reached max buffered recv limit\n");
return NULL;
}
rx_entry = calloc(1, sizeof(*rx_entry) + len);
if (!rx_entry)
return NULL;
SOCK_LOG_INFO("New buffered entry:%p len: %lu, ctx: %p\n",
rx_entry, len, rx_ctx);
rx_entry->is_busy = 1;
rx_entry->is_buffered = 1;
rx_entry->rx_op.dest_iov_len = 1;
rx_entry->iov[0].iov.len = len;
rx_entry->iov[0].iov.addr = (uintptr_t) (rx_entry + 1);
rx_entry->total_len = len;
rx_ctx->buffered_len += len;
dlist_insert_tail(&rx_entry->entry, &rx_ctx->rx_buffered_list);
rx_entry->is_busy = 1;
rx_entry->is_tagged = 0;
return rx_entry;
}
示例6: rxd_ep_send_rts
static ssize_t rxd_ep_send_rts(struct rxd_ep *rxd_ep, fi_addr_t rxd_addr)
{
struct rxd_pkt_entry *pkt_entry;
struct rxd_rts_pkt *rts_pkt;
ssize_t ret;
size_t addrlen;
pkt_entry = rxd_get_tx_pkt(rxd_ep);
if (!pkt_entry)
return -FI_ENOMEM;
rts_pkt = (struct rxd_rts_pkt *) (pkt_entry->pkt);
pkt_entry->pkt_size = sizeof(*rts_pkt) + rxd_ep->tx_prefix_size;
pkt_entry->peer = rxd_addr;
rts_pkt->base_hdr.version = RXD_PROTOCOL_VERSION;
rts_pkt->base_hdr.type = RXD_RTS;
rts_pkt->rts_addr = rxd_addr;
addrlen = RXD_NAME_LENGTH;
memset(rts_pkt->source, 0, RXD_NAME_LENGTH);
ret = fi_getname(&rxd_ep->dg_ep->fid, (void *) rts_pkt->source,
&addrlen);
if (ret) {
ofi_buf_free(pkt_entry);
return ret;
}
rxd_ep_send_pkt(rxd_ep, pkt_entry);
rxd_insert_unacked(rxd_ep, rxd_addr, pkt_entry);
dlist_insert_tail(&rxd_ep->peers[rxd_addr].entry, &rxd_ep->rts_sent_list);
return 0;
}
示例7: sock_ep_rx_ctx
static int sock_ep_rx_ctx(struct fid_ep *ep, int index, struct fi_rx_attr *attr,
struct fid_ep **rx_ep, void *context)
{
struct sock_ep *sock_ep;
struct sock_rx_ctx *rx_ctx;
sock_ep = container_of(ep, struct sock_ep, ep);
if (index >= sock_ep->ep_attr.rx_ctx_cnt)
return -FI_EINVAL;
rx_ctx = sock_rx_ctx_alloc(attr, context);
if (!rx_ctx)
return -FI_ENOMEM;
rx_ctx->attr.total_buffered_recv = rx_ctx->attr.total_buffered_recv ?
rx_ctx->attr.total_buffered_recv : SOCK_EP_MAX_BUFF_RECV;
rx_ctx->rx_id = index;
rx_ctx->ep = sock_ep;
rx_ctx->domain = sock_ep->domain;
dlist_insert_tail(&sock_ep->rx_ctx_entry, &rx_ctx->ep_list);
rx_ctx->ctx.fid.ops = &sock_ctx_ops;
rx_ctx->ctx.ops = &sock_ctx_ep_ops;
rx_ctx->ctx.msg = &sock_ep_msg_ops;
rx_ctx->ctx.tagged = &sock_ep_tagged;
rx_ctx->min_multi_recv = sock_ep->min_multi_recv;
*rx_ep = &rx_ctx->ctx;
sock_ep->rx_array[index] = rx_ctx;
atomic_inc(&sock_ep->num_rx_ctx);
atomic_inc(&sock_ep->domain->ref);
return 0;
}
示例8: rxd_ep_send_ack
void rxd_ep_send_ack(struct rxd_ep *rxd_ep, fi_addr_t peer)
{
struct rxd_pkt_entry *pkt_entry;
struct rxd_ack_pkt *ack;
pkt_entry = rxd_get_tx_pkt(rxd_ep);
if (!pkt_entry) {
FI_WARN(&rxd_prov, FI_LOG_EP_CTRL, "Unable to send ack\n");
return;
}
ack = (struct rxd_ack_pkt *) (pkt_entry->pkt);
pkt_entry->pkt_size = sizeof(*ack) + rxd_ep->tx_prefix_size;
pkt_entry->peer = peer;
ack->base_hdr.version = RXD_PROTOCOL_VERSION;
ack->base_hdr.type = RXD_ACK;
ack->base_hdr.peer = rxd_ep->peers[peer].peer_addr;
ack->base_hdr.seq_no = rxd_ep->peers[peer].rx_seq_no;
ack->ext_hdr.rx_id = rxd_ep->peers[peer].rx_window;
rxd_ep->peers[peer].last_tx_ack = ack->base_hdr.seq_no;
dlist_insert_tail(&pkt_entry->d_entry, &rxd_ep->ctrl_pkts);
if (rxd_ep_send_pkt(rxd_ep, pkt_entry)) {
dlist_remove(&pkt_entry->d_entry);
ofi_buf_free(pkt_entry);
}
}
示例9: sock_ep_tx_ctx
static int sock_ep_tx_ctx(struct fid_ep *ep, int index, struct fi_tx_attr *attr,
struct fid_ep **tx_ep, void *context)
{
struct sock_ep *sock_ep;
struct sock_tx_ctx *tx_ctx;
sock_ep = container_of(ep, struct sock_ep, ep);
if (sock_ep->attr->fclass != FI_CLASS_SEP ||
index >= sock_ep->attr->ep_attr.tx_ctx_cnt)
return -FI_EINVAL;
tx_ctx = sock_tx_ctx_alloc(&sock_ep->tx_attr, context, 0);
if (!tx_ctx)
return -FI_ENOMEM;
tx_ctx->tx_id = index;
tx_ctx->ep_attr = sock_ep->attr;
tx_ctx->domain = sock_ep->attr->domain;
tx_ctx->av = sock_ep->attr->av;
dlist_insert_tail(&sock_ep->attr->tx_ctx_entry, &tx_ctx->ep_list);
tx_ctx->fid.ctx.fid.ops = &sock_ctx_ops;
tx_ctx->fid.ctx.ops = &sock_ctx_ep_ops;
tx_ctx->fid.ctx.msg = &sock_ep_msg_ops;
tx_ctx->fid.ctx.tagged = &sock_ep_tagged;
tx_ctx->fid.ctx.rma = &sock_ep_rma;
tx_ctx->fid.ctx.atomic = &sock_ep_atomic;
*tx_ep = &tx_ctx->fid.ctx;
sock_ep->attr->tx_array[index] = tx_ctx;
atomic_inc(&sock_ep->attr->num_tx_ctx);
atomic_inc(&sock_ep->attr->domain->ref);
return 0;
}
示例10: ofi_domain_init
int ofi_domain_init(struct fid_fabric *fabric_fid, const struct fi_info *info,
struct util_domain *domain, void *context)
{
struct util_fabric *fabric;
int ret;
fabric = container_of(fabric_fid, struct util_fabric, fabric_fid);
domain->fabric = fabric;
domain->prov = fabric->prov;
ret = util_domain_init(domain, info);
if (ret) {
free(domain);
return ret;
}
domain->domain_fid.fid.fclass = FI_CLASS_DOMAIN;
domain->domain_fid.fid.context = context;
/*
* domain ops set by provider
*/
domain->domain_fid.mr = &util_domain_mr_ops;
fastlock_acquire(&fabric->lock);
dlist_insert_tail(&domain->list_entry, &fabric->domain_list);
fastlock_release(&fabric->lock);
ofi_atomic_inc32(&fabric->ref);
return 0;
}
示例11: rxd_insert_unacked
void rxd_insert_unacked(struct rxd_ep *ep, fi_addr_t peer,
struct rxd_pkt_entry *pkt_entry)
{
dlist_insert_tail(&pkt_entry->d_entry,
&ep->peers[peer].unacked);
ep->peers[peer].unacked_cnt++;
}
示例12: wind_msgbox_post
w_err_t wind_msgbox_post(w_msgbox_s *msgbox,w_msg_s *pmsg)
{
w_thread_s *thread;
WIND_ASSERT_RETURN(msgbox != W_NULL,W_ERR_PTR_NULL);
WIND_ASSERT_RETURN(pmsg != W_NULL,W_ERR_PTR_NULL);
WIND_ASSERT_RETURN(msgbox->obj.magic == WIND_MSGBOX_MAGIC,W_ERR_FAIL);
WIND_ASSERT_RETURN(msgbox->owner,W_ERR_FAIL);
//将消息加入邮箱
wind_disable_switch();
dlist_insert_tail(&msgbox->msglist,&pmsg->msgnode);
msgbox->msgnum ++;
//激活被阻塞的线程
thread = msgbox->owner;
if((thread->runstat != THREAD_STATUS_SLEEP)
|| (thread->cause != CAUSE_MSG))
{
wind_enable_switch();
return W_ERR_OK;
}
msgbox->owner->runstat = THREAD_STATUS_READY;
wind_enable_switch();
_wind_thread_dispatch();//切换线程
return W_ERR_OK;
}
示例13: sock_ep_rx_ctx
static int sock_ep_rx_ctx(struct fid_ep *ep, int index, struct fi_rx_attr *attr,
struct fid_ep **rx_ep, void *context)
{
struct sock_ep *sock_ep;
struct sock_rx_ctx *rx_ctx;
sock_ep = container_of(ep, struct sock_ep, ep);
if (sock_ep->attr->fclass != FI_CLASS_SEP ||
index >= sock_ep->attr->ep_attr.rx_ctx_cnt)
return -FI_EINVAL;
rx_ctx = sock_rx_ctx_alloc(attr ? attr : &sock_ep->rx_attr, context, 0);
if (!rx_ctx)
return -FI_ENOMEM;
rx_ctx->rx_id = index;
rx_ctx->ep_attr = sock_ep->attr;
rx_ctx->domain = sock_ep->attr->domain;
rx_ctx->av = sock_ep->attr->av;
dlist_insert_tail(&sock_ep->attr->rx_ctx_entry, &rx_ctx->ep_list);
rx_ctx->ctx.fid.ops = &sock_ctx_ops;
rx_ctx->ctx.ops = &sock_ctx_ep_ops;
rx_ctx->ctx.msg = &sock_ep_msg_ops;
rx_ctx->ctx.tagged = &sock_ep_tagged;
rx_ctx->min_multi_recv = sock_ep->attr->min_multi_recv;
*rx_ep = &rx_ctx->ctx;
sock_ep->attr->rx_array[index] = rx_ctx;
atomic_inc(&sock_ep->attr->num_rx_ctx);
atomic_inc(&sock_ep->attr->domain->ref);
return 0;
}
示例14: client_new
static client client_new(int fd, int sock) {
client c;
if (NEW(c) == NULL)
return NULL;
/* FIXME */
net_nonblock(fd, NULL, 0);
net_tcp_nodelay(fd, NULL, 0);
if (create_file_event(el, fd, EVENT_READABLE, read_from_client, c) == -1) {
close(fd);
client_free(c);
return NULL;
}
c->fd = fd;
pthread_spin_init(&c->lock, 0);
c->sock = sock;
c->flags = 0;
c->inpos = 0;
c->argc = 0;
c->argv = NULL;
c->outpos = 0;
c->reply = ring_new();
c->sentlen = 0;
c->refcount = 0;
c->eagcount = 0;
c->authenticated = 0;
dlist_lock(clients);
dlist_insert_tail(clients, c);
dlist_unlock(clients);
return c;
}
示例15: __gnix_buddy_create_lists
static inline int __gnix_buddy_create_lists(gnix_buddy_alloc_handle_t
*alloc_handle)
{
uint32_t i, offset = 0;
alloc_handle->nlists = (uint32_t) __gnix_buddy_log2(alloc_handle->max /
MIN_BLOCK_SIZE) + 1;
alloc_handle->lists = calloc(1, sizeof(struct dlist_entry) *
alloc_handle->nlists);
if (unlikely(!alloc_handle->lists)) {
GNIX_WARN(FI_LOG_EP_CTRL,
"Could not create buddy allocator lists.\n");
return -FI_ENOMEM;
}
for (i = 0; i < alloc_handle->nlists; i++) {
dlist_init(alloc_handle->lists + i);
}
/* Insert free blocks of size max in sorted order into last list */
for (i = 0; i < alloc_handle->len / alloc_handle->max; i++) {
dlist_insert_tail((void *) ((uint8_t *) alloc_handle->base +
offset),
alloc_handle->lists +
alloc_handle->nlists - 1);
offset += alloc_handle->max;
}
return FI_SUCCESS;
}