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


C++ LOCK_INIT函数代码示例

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


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

示例1: shutdown_osinet

void
shutdown_osinet(void)
{
    AFS_STATCNT(shutdown_osinet);
#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
    if (afs_cold_shutdown) {
	struct osi_packet *tp;

	while ((tp = freePacketList)) {
	    freePacketList = tp->next;
	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
#ifdef  KERNEL_HAVE_PIN
	    unpin(tp, AFS_LRALLOCSIZ);
#endif
	}

	while ((tp = freeSmallList)) {
	    freeSmallList = tp->next;
	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
#ifdef  KERNEL_HAVE_PIN
	    unpin(tp, AFS_SMALLOCSIZ);
#endif
	}
	LOCK_INIT(&osi_fsplock, "osi_fsplock");
	LOCK_INIT(&osi_flplock, "osi_flplock");
    }
#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
    if (afs_stats_cmperf.LargeBlocksActive ||
	afs_stats_cmperf.SmallBlocksActive)
    {
	afs_warn("WARNING: not all blocks freed: large %d small %d\n",
		 afs_stats_cmperf.LargeBlocksActive,
		 afs_stats_cmperf.SmallBlocksActive);
    }
}
开发者ID:bagdxk,项目名称:openafs,代码行数:35,代码来源:afs_osi_alloc.c

示例2: event_alloc

ACL_EVENT *event_new_select_thr(void)
{
	EVENT_SELECT_THR *event_thr;

	event_thr = (EVENT_SELECT_THR*) event_alloc(sizeof(EVENT_SELECT_THR));

	snprintf(event_thr->event.event.name, sizeof(event_thr->event.event.name),
		 "thread events - select");
	event_thr->event.event.event_mode           = ACL_EVENT_SELECT;
	event_thr->event.event.use_thread           = 1;
	event_thr->event.event.loop_fn              = event_loop;
	event_thr->event.event.free_fn              = event_free;
	event_thr->event.event.add_dog_fn           = event_add_dog;
	event_thr->event.event.enable_read_fn       = event_enable_read;
	event_thr->event.event.enable_write_fn      = event_enable_write;
	event_thr->event.event.enable_listen_fn     = event_enable_listen;
	event_thr->event.event.disable_readwrite_fn = event_disable_readwrite;
	event_thr->event.event.isrset_fn            = event_isrset;
	event_thr->event.event.iswset_fn            = event_iswset;
	event_thr->event.event.isxset_fn            = event_isxset;
	event_thr->event.event.timer_request        = event_timer_request_thr;
	event_thr->event.event.timer_cancel         = event_timer_cancel_thr;
	event_thr->event.event.timer_keep           = event_timer_keep_thr;
	event_thr->event.event.timer_ifkeep         = event_timer_ifkeep_thr;

        FD_ZERO(&event_thr->rmask);
        FD_ZERO(&event_thr->wmask);
        FD_ZERO(&event_thr->xmask);

	LOCK_INIT(&event_thr->event.tm_mutex);
	LOCK_INIT(&event_thr->event.tb_mutex);

	return (ACL_EVENT *) event_thr;
}
开发者ID:FlowSea,项目名称:acl,代码行数:34,代码来源:events_select_thr.c

示例3: init_branches

int init_branches(struct opt_s *opt)
{
  int err;
  opt->membranch =
    (struct entity_list_branch *)malloc(sizeof(struct entity_list_branch));
  CHECK_ERR_NONNULL(opt->membranch, "membranch malloc");
  opt->diskbranch =
    (struct entity_list_branch *)malloc(sizeof(struct entity_list_branch));
  CHECK_ERR_NONNULL(opt->diskbranch, "diskbranch malloc");

  opt->diskbranch->mutex_free = 0;
  opt->membranch->mutex_free = 0;

  opt->membranch->freelist = NULL;
  opt->membranch->busylist = NULL;
  opt->membranch->loadedlist = NULL;
  opt->diskbranch->freelist = NULL;
  opt->diskbranch->busylist = NULL;
  opt->diskbranch->loadedlist = NULL;

  err = LOCK_INIT(&(opt->membranch->branchlock));
  CHECK_ERR("branchlock");
  err = LOCK_INIT(&(opt->diskbranch->branchlock));
  CHECK_ERR("branchlock");
  err = pthread_cond_init(&(opt->membranch->busysignal), NULL);
  CHECK_ERR("busysignal");
  err = pthread_cond_init(&(opt->diskbranch->busysignal), NULL);
  CHECK_ERR("busysignal");
  return 0;
}
开发者ID:tlsalmin,项目名称:vlbi-streamer,代码行数:30,代码来源:streamer.c

示例4: booster_fdtable_alloc

booster_fdtable_t *
booster_fdtable_alloc (void)
{
        booster_fdtable_t *fdtable = NULL;
        int32_t            ret = -1;

        fdtable = CALLOC (1, sizeof (*fdtable));
        GF_VALIDATE_OR_GOTO ("booster-fd", fdtable, out);

        LOCK_INIT (&fdtable->lock);

        LOCK (&fdtable->lock);
        {
                ret = booster_fdtable_expand (fdtable, 0);
        }
        UNLOCK (&fdtable->lock);

        if (ret == -1) {
                gf_log ("booster-fd", GF_LOG_ERROR, "FD-table allocation "
                        "failed");
                FREE (fdtable);
                fdtable = NULL;
        }

out:
        return fdtable;
}
开发者ID:Gaurav-Gangalwar,项目名称:glusterfs,代码行数:27,代码来源:booster-fd.c

示例5: helper_xlator_init

/*
 * Helper functions
 */
static xlator_t *
helper_xlator_init(uint32_t num_types)
{
    xlator_t *xl;
    int i, ret;

    REQUIRE(num_types > 0);

    xl = test_calloc(1, sizeof(xlator_t));
    assert_non_null(xl);
    xl->mem_acct.num_types = num_types;
    xl->mem_acct.rec = test_calloc(num_types, sizeof(struct mem_acct_rec));
    assert_non_null(xl->mem_acct.rec);

    xl->ctx = test_calloc(1, sizeof(glusterfs_ctx_t));
    assert_non_null(xl->ctx);

    for (i = 0; i < num_types; i++) {
        ret = LOCK_INIT(&(xl->mem_acct.rec[i].lock));
        assert_int_equal(ret, 0);
    }

    ENSURE(num_types == xl->mem_acct.num_types);
    ENSURE(NULL != xl);

    return xl;
}
开发者ID:mmadhusu,项目名称:glusterfs,代码行数:30,代码来源:mem_pool_unittest.c

示例6: gf_clienttable_alloc

clienttable_t *
gf_clienttable_alloc (void)
{
        clienttable_t *clienttable = NULL;
        int            result = 0;

        clienttable =
                GF_CALLOC (1, sizeof (clienttable_t), gf_common_mt_clienttable_t);
        if (!clienttable)
                return NULL;

        LOCK_INIT (&clienttable->lock);

        result = gf_client_clienttable_expand (clienttable,
                                               GF_CLIENTTABLE_INITIAL_SIZE);
        if (result != 0) {
                gf_msg ("client_t", GF_LOG_ERROR, 0,
                        LG_MSG_EXPAND_CLIENT_TABLE_FAILED,
                        "gf_client_clienttable_expand failed");
                GF_FREE (clienttable);
                return NULL;
        }

        return clienttable;
}
开发者ID:rlugojr,项目名称:glusterfs,代码行数:25,代码来源:client_t.c

示例7: iiEllisInit

//******************************************************************************
// Function:   iiEllisInit()
// Parameters: None
//
// Returns:    Nothing
//
// Description:
//
// This routine performs any required initialization of the iiEllis subsystem.
//
//******************************************************************************
static void
iiEllisInit(void)
{
    pDelayTimer = kmalloc ( sizeof (struct timer_list), GFP_KERNEL );
    init_waitqueue_head(&pDelayWait);
    LOCK_INIT(&Dl_spinlock);
}
开发者ID:niubl,项目名称:camera_project,代码行数:18,代码来源:i2ellis.c

示例8: exporter_add

struct afs_exporter *
exporter_add(afs_int32 size, struct exporterops *ops, afs_int32 state,
             afs_int32 type, char *data)
{
    struct afs_exporter *ex, *op;
    afs_int32 length;

    AFS_STATCNT(exporter_add);
    if (!init_xexported) {
        init_xexported = 1;
        LOCK_INIT(&afs_xexp, "afs_xexp");
    }
    length = (size ? size : sizeof(struct afs_exporter));
    ex = (struct afs_exporter *)afs_osi_Alloc(length);
    memset(ex, 0, length);
    ObtainWriteLock(&afs_xexp, 308);
    for (op = root_exported; op; op = op->exp_next) {
        if (!op->exp_next)
            break;
    }
    if (op)
        op->exp_next = ex;
    else
        root_exported = ex;
    ReleaseWriteLock(&afs_xexp);
    ex->exp_next = 0;
    ex->exp_op = ops;
    ex->exp_states = state;
    ex->exp_data = data;
    ex->exp_type = type;
    return ex;
}
开发者ID:stevenjenkins,项目名称:openafs,代码行数:32,代码来源:afs_exporter.c

示例9: sizeof

cevents *cevents_create() {
	cevents *evts;
	int len;
	len = sizeof(cevents);
	evts = (cevents *)jmalloc(len);
	memset((void *)evts, len, 0);
	evts->events = jmalloc(sizeof(cevent) * MAX_EVENTS);
	evts->fired = jmalloc(sizeof(cevent_fired) * MAX_EVENTS);
	evts->fired_queue = clist_create();
	LOCK_INIT(&evts->qlock);
	LOCK_INIT(&evts->lock);
	cevents_create_priv_impl(evts);
	evts->poll_sec = 0;
	evts->poll_ms = 0;
	return evts;
}
开发者ID:Joinhack,项目名称:thr_socket,代码行数:16,代码来源:cevent.c

示例10: glusterfs_ctx_defaults_init

static int
glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
{
        cmd_args_t    *cmd_args = NULL;
        struct rlimit  lim = {0, };
        call_pool_t   *pool = NULL;

        xlator_mem_acct_init (THIS, cli_mt_end);

        ctx->process_uuid = generate_uuid ();
        if (!ctx->process_uuid)
                return -1;

        ctx->page_size  = 128 * GF_UNIT_KB;

        ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size);
        if (!ctx->iobuf_pool)
                return -1;

        ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
        if (!ctx->event_pool)
                return -1;

        pool = GF_CALLOC (1, sizeof (call_pool_t),
                          cli_mt_call_pool_t);
        if (!pool)
                return -1;

        /* frame_mem_pool size 112 * 16k */
        pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384);

        if (!pool->frame_mem_pool)
                return -1;

        /* stack_mem_pool size 256 * 8k */
        pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192); 

        if (!pool->stack_mem_pool)
                return -1;

        ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);
        if (!ctx->stub_mem_pool)
                return -1;

        INIT_LIST_HEAD (&pool->all_frames);
        LOCK_INIT (&pool->lock);
        ctx->pool = pool;

        pthread_mutex_init (&(ctx->lock), NULL);

        cmd_args = &ctx->cmd_args;

        INIT_LIST_HEAD (&cmd_args->xlator_options);

        lim.rlim_cur = RLIM_INFINITY;
        lim.rlim_max = RLIM_INFINITY;
        setrlimit (RLIMIT_CORE, &lim);

        return 0;
}
开发者ID:Dhandapani,项目名称:glusterfs,代码行数:60,代码来源:cli.c

示例11: odp_queue_init_global

int odp_queue_init_global(void)
{
	uint32_t i;
	odp_shm_t shm;

	ODP_DBG("Queue init ... ");

	shm = odp_shm_reserve("odp_queues",
			      sizeof(queue_table_t),
			      sizeof(queue_entry_t), 0);

	queue_tbl = odp_shm_addr(shm);

	if (queue_tbl == NULL)
		return -1;

	memset(queue_tbl, 0, sizeof(queue_table_t));

	for (i = 0; i < ODP_CONFIG_QUEUES; i++) {
		/* init locks */
		queue_entry_t *queue = get_qentry(i);
		LOCK_INIT(queue);
		queue->s.handle = queue_from_id(i);
	}

	ODP_DBG("done\n");
	ODP_DBG("Queue init global\n");
	ODP_DBG("  struct queue_entry_s size %zu\n",
		sizeof(struct queue_entry_s));
	ODP_DBG("  queue_entry_t size        %zu\n",
		sizeof(queue_entry_t));
	ODP_DBG("\n");
	__k1_wmb();
	return 0;
}
开发者ID:rahulgvf,项目名称:odp-mppa,代码行数:35,代码来源:odp_queue.c

示例12: sink_init

/***************sink operations *****************/
void  sink_init(Sink* sink)
{
    if(!sink)
	return;

	LOCK_INIT (&sink->lock);
    //pthread_mutex_init(&sink->lock, 0);
    sink->busy = 0;
}
开发者ID:mycp,项目名称:mycp,代码行数:10,代码来源:sink.c

示例13: DInit

void
DInit(int abuffers)
{
    /* Initialize the venus buffer system. */
    register int i;
    register struct buffer *tb;
#if defined(AFS_USEBUFFERS)
    struct buf *tub;		/* unix buffer for allocation */
#endif

    AFS_STATCNT(DInit);
    if (dinit_flag)
	return;
    dinit_flag = 1;
#if defined(AFS_USEBUFFERS)
    /* round up to next multiple of NPB, since we allocate multiple pages per chunk */
    abuffers = ((abuffers - 1) | (NPB - 1)) + 1;
#endif
    LOCK_INIT(&afs_bufferLock, "afs_bufferLock");
    Buffers =
	(struct buffer *)afs_osi_Alloc(abuffers * sizeof(struct buffer));
#if !defined(AFS_USEBUFFERS)
    BufferData = (char *)afs_osi_Alloc(abuffers * AFS_BUFFER_PAGESIZE);
#endif
    timecounter = 1;
    afs_stats_cmperf.bufAlloced = nbuffers = abuffers;
    for (i = 0; i < PHSIZE; i++)
	phTable[i] = 0;
    for (i = 0; i < abuffers; i++) {
#if defined(AFS_USEBUFFERS)
	if ((i & (NPB - 1)) == 0) {
	    /* time to allocate a fresh buffer */
	    tub = geteblk(AFS_BUFFER_PAGESIZE * NPB);
	    BufferData = (char *)tub->b_un.b_addr;
	}
#endif
	/* Fill in each buffer with an empty indication. */
	tb = &Buffers[i];
	tb->fid = NULLIDX;
	tb->inode = 0;
	tb->accesstime = 0;
	tb->lockers = 0;
#if defined(AFS_USEBUFFERS)
	if ((i & (NPB - 1)) == 0)
	    tb->bufp = tub;
	else
	    tb->bufp = 0;
	tb->data = &BufferData[AFS_BUFFER_PAGESIZE * (i & (NPB - 1))];
#else
	tb->data = &BufferData[AFS_BUFFER_PAGESIZE * i];
#endif
	tb->hashIndex = 0;
	tb->dirty = 0;
	AFS_RWLOCK_INIT(&tb->lock, "buffer lock");
    }
    return;
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:57,代码来源:afs_buffer.c

示例14: __event_slot_alloc

static int
__event_slot_alloc (struct event_pool *event_pool, int fd)
{
        int  i = 0;
	int  table_idx = -1;
	int  gen = -1;
	struct event_slot_epoll *table = NULL;

	for (i = 0; i < EVENT_EPOLL_TABLES; i++) {
		switch (event_pool->slots_used[i]) {
		case EVENT_EPOLL_SLOTS:
			continue;
		case 0:
			if (!event_pool->ereg[i]) {
				table = __event_newtable (event_pool, i);
				if (!table)
					return -1;
			} else {
                                table = event_pool->ereg[i];
                        }
			break;
		default:
			table = event_pool->ereg[i];
			break;
		}

		if (table)
			/* break out of the loop */
			break;
	}

	if (!table)
		return -1;

	table_idx = i;

	for (i = 0; i < EVENT_EPOLL_SLOTS; i++) {
		if (table[i].fd == -1) {
			/* wipe everything except bump the generation */
			gen = table[i].gen;
			memset (&table[i], 0, sizeof (table[i]));
			table[i].gen = gen + 1;

			LOCK_INIT (&table[i].lock);

			table[i].fd = fd;
			event_pool->slots_used[table_idx]++;

			break;
		}
	}

	return table_idx * EVENT_EPOLL_SLOTS + i;
}
开发者ID:RichWpg,项目名称:glusterfs,代码行数:54,代码来源:event-epoll.c

示例15: SNetWorkerInit

/* Init worker data */
void SNetWorkerInit(void)
{
  snet_workers = SNetNodeGetWorkers();
  snet_worker_count = SNetNodeGetWorkerCount();
  snet_thief_limit = SNetThreadingThieves();
  if (snet_thief_limit > 1) {
    LOCK_INIT2(snet_idle_lock, snet_thief_limit);
  } else {
    LOCK_INIT(snet_idle_lock);
  }
}
开发者ID:nguyenvuthiennga,项目名称:snet-rts,代码行数:12,代码来源:xworker.c


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