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

C++ pool_init函数代码示例

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

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



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

示例1: mbinit

/*
 * Initialize the mbuf allocator.
 */
void
mbinit(void)
{
	int i;

#if DIAGNOSTIC
	if (mclsizes[0] != MCLBYTES)
		panic("mbinit: the smallest cluster size != MCLBYTES");
	if (mclsizes[nitems(mclsizes) - 1] != MAXMCLBYTES)
		panic("mbinit: the largest cluster size != MAXMCLBYTES");
#endif

	pool_init(&mbpool, MSIZE, 0, 0, 0, "mbufpl", NULL);
	pool_setipl(&mbpool, IPL_NET);
	pool_set_constraints(&mbpool, &kp_dma_contig);
	pool_setlowat(&mbpool, mblowat);

	pool_init(&mtagpool, PACKET_TAG_MAXSIZE + sizeof(struct m_tag),
	    0, 0, 0, "mtagpl", NULL);
	pool_setipl(&mtagpool, IPL_NET);

	for (i = 0; i < nitems(mclsizes); i++) {
		snprintf(mclnames[i], sizeof(mclnames[0]), "mcl%dk",
		    mclsizes[i] >> 10);
		pool_init(&mclpools[i], mclsizes[i], 0, 0, 0,
		    mclnames[i], NULL);
		pool_setipl(&mclpools[i], IPL_NET);
		pool_set_constraints(&mclpools[i], &kp_dma_contig);
		pool_setlowat(&mclpools[i], mcllowat);
	}

	nmbclust_update();
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:36,代码来源:uipc_mbuf.c


示例2: dmoverioattach

/*
 * dmoverioattach:
 *
 *	Pseudo-device attach routine.
 */
void
dmoverioattach(int count)
{

	pool_init(&dmio_state_pool, sizeof(struct dmio_state),
	    0, 0, 0, "dmiostate", NULL, IPL_SOFTCLOCK);
	pool_init(&dmio_usrreq_state_pool, sizeof(struct dmio_usrreq_state),
	    0, 0, 0, "dmiourstate", NULL, IPL_SOFTCLOCK);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:14,代码来源:dmover_io.c


示例3: time_init

/*
 * Initialize timekeeping.
 */
void
time_init(void)
{

	pool_init(&ptimer_pool, sizeof(struct ptimer), 0, 0, 0, "ptimerpl",
	    &pool_allocator_nointr, IPL_NONE);
	pool_init(&ptimers_pool, sizeof(struct ptimers), 0, 0, 0, "ptimerspl",
	    &pool_allocator_nointr, IPL_NONE);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:12,代码来源:kern_time.c


示例4: ext2fs_init

int
ext2fs_init(struct vfsconf *vfsp)
{
	pool_init(&ext2fs_inode_pool, sizeof(struct inode), 0, 0, 0,
	    "ext2inopl", &pool_allocator_nointr);
	pool_init(&ext2fs_dinode_pool, sizeof(struct ext2fs_dinode), 0, 0, 0,
	    "ext2dinopl", &pool_allocator_nointr);

	return (ufs_init(vfsp));
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:10,代码来源:ext2fs_vfsops.c


示例5: ext2fs_init

void
ext2fs_init(void)
{

	pool_init(&ext2fs_inode_pool, sizeof(struct inode), 0, 0, 0,
	    "ext2fsinopl", &pool_allocator_nointr, IPL_NONE);
	pool_init(&ext2fs_dinode_pool, sizeof(struct ext2fs_dinode), 0, 0, 0,
	    "ext2dinopl", &pool_allocator_nointr, IPL_NONE);
	ufs_init();
}
开发者ID:Hooman3,项目名称:minix,代码行数:10,代码来源:ext2fs_vfsops.c


示例6: ext2fs_init

int
ext2fs_init(struct vfsconf *vfsp)
{
	pool_init(&ext2fs_inode_pool, sizeof(struct inode), 0, 0, PR_WAITOK,
	    "ext2inopl", NULL);
	pool_init(&ext2fs_dinode_pool, sizeof(struct ext2fs_dinode), 0, 0,
	    PR_WAITOK, "ext2dinopl", NULL);

	return (ufs_init(vfsp));
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:10,代码来源:ext2fs_vfsops.c


示例7: udf_init

int
udf_init(struct vfsconf *foo)
{
	pool_init(&udf_trans_pool, MAXNAMLEN * sizeof(unicode_t), 0, 0,
	    PR_WAITOK, "udftrpl", NULL);
	pool_init(&unode_pool, sizeof(struct unode), 0, 0,
	    PR_WAITOK, "udfndpl", NULL);
	pool_init(&udf_ds_pool, sizeof(struct udf_dirstream), 0, 0,
	    PR_WAITOK, "udfdspl", NULL);

	return (0);
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:12,代码来源:udf_vfsops.c


示例8: udf_init

int
udf_init(struct vfsconf *foo)
{
	pool_init(&udf_trans_pool, MAXNAMLEN * sizeof(unicode_t), 0, 0, 0,
	    "udftrpl", &pool_allocator_nointr);
	pool_init(&unode_pool, sizeof(struct unode), 0, 0, 0,
	    "udfndpl", &pool_allocator_nointr);
	pool_init(&udf_ds_pool, sizeof(struct udf_dirstream), 0, 0, 0,
	    "udfdspl", &pool_allocator_nointr);

	return (0);
}
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:12,代码来源:udf_vfsops.c


示例9: nfs_node_init

/*
 * Reinitialize inode hash table.
 */
void
nfs_node_init(void)
{

	pool_init(&nfs_node_pool, sizeof(struct nfsnode), 0, 0, 0, "nfsnodepl",
	    &pool_allocator_nointr, IPL_NONE);
	pool_init(&nfs_vattr_pool, sizeof(struct vattr), 0, 0, 0, "nfsvapl",
	    &pool_allocator_nointr, IPL_NONE);
	if (workqueue_create(&nfs_sillyworkq, "nfssilly", nfs_sillyworker,
	    NULL, PRI_NONE, IPL_NONE, 0) != 0) {
	    	panic("nfs_node_init");
	}
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:16,代码来源:nfs_node.c


示例10: task_dispatcher_init

int task_dispatcher_init(struct task_dispatcher_t** ptd, uint32_t nthreads)
{
   LOGI("Starting task dispatcher with %d threads", nthreads);

   struct task_dispatcher_t* td = malloc(sizeof(struct task_dispatcher_t));
   memset(td, 0, sizeof(struct task_dispatcher_t));
   td->nthreads = nthreads;
   td->running = 1;

   if (pool_init(&td->tasks, MAX_TASKS, sizeof(struct task_t)) != 0)
   {
      return -1;
   }

   pthread_mutex_init(&td->event_lock, NULL);
   pthread_cond_init(&td->event, NULL);

   pthread_mutexattr_init(&td->lock_attr);
   pthread_mutexattr_settype(&td->lock_attr, PTHREAD_MUTEX_RECURSIVE);
   pthread_mutex_init(&td->lock, &td->lock_attr);

   uint32_t i = 0;
   for (i = 0; i < td->nthreads; ++i)
   {
      pthread_create(&td->threads[i], NULL, working_thread, td);
   }

   (*ptd) = td;
   return 0;
}
开发者ID:asqz,项目名称:runner,代码行数:30,代码来源:task_dispatcher.c


示例11: main

int main(int argc,char **argv)
{
	/*线程池中最多3个活动线程*/
	pool_init(3);

	int *workingnum=(int *)malloc(sizeof(int)*10);

	/*连续向线程池中投入10个任务*/
	int i;
	for(i=0;i<10;i++)
	{
		workingnum[i]=i;
		pool_add_worker(myprocess,&workingnum[i]);
	}
	
	/*等待所有任务完成*/	
	sleep(5);
	
	/*销毁线程池*/
	pool_destroy();

	free(workingnum);

	return 0;
}
开发者ID:guiqinghai,项目名称:gqh,代码行数:25,代码来源:pthread_pool.c


示例12: main

int main(void)
{
    go = false;
    finish = false;
    pool_init(&pool);
    
    for(int i = 0;i < NUM_PRODUCER;i++)
    {
        pthread_create(&producer[i], NULL, &producer_runner, (void*)(size_t)i);
    }
    
    for(int i = 0;i < NUM_CONSUMER;i++)
    {
        pthread_create(&producer[i], NULL, &thread_runner, (void*)(size_t)i);
    }
    
    go = true;
    
    sleep(1);
    
    finish = true;
    
    for(int i = 0;i < NUM_PRODUCER;i++)
    {
        pthread_join(producer[i], NULL);
    }
    
    for(int i = 0;i < NUM_CONSUMER;i++)
    {
        pthread_join(consumer[i], NULL);
    }
    return 0;
}
开发者ID:ohmygod12121212,项目名称:schoolwork,代码行数:33,代码来源:main.c


示例13: _ensure_pool_cleanup_gracefully_handles_cleaned_up_pool

static void _ensure_pool_cleanup_gracefully_handles_cleaned_up_pool( void )
{
	pool_t pool;
	pool_init( &pool, 4, 16, allocator_default( ) );
	pool_cleanup( &pool );
	pool_cleanup( &pool );
}
开发者ID:jbrd,项目名称:libmem,代码行数:7,代码来源:pool_tests.c


示例14: _ensure_pool_is_empty_gracefully_handles_cleaned_up_pool

static void _ensure_pool_is_empty_gracefully_handles_cleaned_up_pool( void )
{
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	pool_cleanup( &pool );
	TEST_REQUIRE( pool_is_empty( &pool ) != 0 );
}
开发者ID:jbrd,项目名称:libmem,代码行数:7,代码来源:pool_tests.c


示例15: nfs4_acls_init

int nfs4_acls_init(void)
{
    LogDebug(COMPONENT_NFS_V4_ACL, "Initialize NFSv4 ACLs");
    LogDebug(COMPONENT_NFS_V4_ACL,
             "sizeof(fsal_ace_t)=%zu, sizeof(fsal_acl_t)=%zu",
             sizeof(fsal_ace_t), sizeof(fsal_acl_t));

    /* Initialize memory pool of ACLs. */
    fsal_acl_pool =
        pool_init(NULL, sizeof(fsal_acl_t), pool_basic_substrate, NULL,
                  NULL, NULL);

    /* Create hash table. */
    fsal_acl_hash = hashtable_init(&fsal_acl_hash_config);

    if (!fsal_acl_hash) {
        LogCrit(COMPONENT_NFS_V4_ACL,
                "ERROR creating hash table for NFSv4 ACLs");
        return NFS_V4_ACL_INTERNAL_ERROR;
    }

    nfs4_acls_test();

    return NFS_V4_ACL_SUCCESS;
}
开发者ID:manusfreedom,项目名称:nfs-ganesha,代码行数:25,代码来源:nfs4_acls.c


示例16: _ensure_pool_is_empty_returns_non_zero_on_empty_legitimate_pool

static void _ensure_pool_is_empty_returns_non_zero_on_empty_legitimate_pool( void )
{
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	TEST_REQUIRE( pool_is_empty( &pool ) == 0 );
	pool_cleanup( &pool );
}
开发者ID:jbrd,项目名称:libmem,代码行数:7,代码来源:pool_tests.c


示例17: bufinit

/*
 * Initialize buffers and hash links for buffers.
 */
void
bufinit(void)
{
	struct buf *bp;
	struct bqueues *dp;
	int i;
	int base, residual;

	pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", NULL);
	for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
		TAILQ_INIT(dp);
	bufhashtbl = hashinit(nbuf, M_CACHE, M_WAITOK, &bufhash);
	base = bufpages / nbuf;
	residual = bufpages % nbuf;
	for (i = 0; i < nbuf; i++) {
		bp = &buf[i];
		bzero((char *)bp, sizeof *bp);
		bp->b_dev = NODEV;
		bp->b_vnbufs.le_next = NOLIST;
		bp->b_data = buffers + i * MAXBSIZE;
		LIST_INIT(&bp->b_dep);
		if (i < residual)
			bp->b_bufsize = (base + 1) * PAGE_SIZE;
		else
			bp->b_bufsize = base * PAGE_SIZE;
		bp->b_flags = B_INVAL;
		if (bp->b_bufsize) {
			dp = &bufqueues[BQ_CLEAN];
			numfreepages += btoc(bp->b_bufsize);
			numcleanpages += btoc(bp->b_bufsize);
		} else {
			dp = &bufqueues[BQ_EMPTY];
			numemptybufs++;
		}
		binsheadfree(bp, dp);
		binshash(bp, &invalhash);
	}

	hidirtypages = bufpages / 4;
	lodirtypages = hidirtypages / 2;

	/*
	 * Reserve 5% of bufpages for syncer's needs,
	 * but not more than 25% and if possible
	 * not less then 2 * MAXBSIZE. locleanpages
	 * value must be not too small, but probably
	 * there are no reason to set it more than 1-2 MB.
	 */
	locleanpages = bufpages / 20;
	if (locleanpages < btoc(2 * MAXBSIZE))
		locleanpages = btoc(2 * MAXBSIZE);
	if (locleanpages > bufpages / 4)
		locleanpages = bufpages / 4;
	if (locleanpages > btoc(2 * 1024 * 1024))
		locleanpages = btoc(2 * 1024 * 1024);

#ifdef DEBUG
	mincleanpages = locleanpages;
#endif
}
开发者ID:NKSG,项目名称:INTER_MANET_NS3,代码行数:63,代码来源:vfs_bio.c


示例18: uvm_anon_init

/*
 * allocate anons
 */
void
uvm_anon_init()
{
	pool_init(&uvm_anon_pool, sizeof(struct vm_anon), 0, 0, 0, "anonpl",
	    &pool_allocator_nointr);
	pool_sethiwat(&uvm_anon_pool, uvmexp.free / 16);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:10,代码来源:uvm_anon.c


示例19: vfsinit

/* Initialize the vnode structures and initialize each file system type. */
void
vfsinit(void)
{
	int i;
	struct vfsconf *vfsconflist;
	int vfsconflistlen;

	pool_init(&namei_pool, MAXPATHLEN, 0, 0, 0, "namei",
	    &pool_allocator_nointr);

	/* Initialize the vnode table. */
	vntblinit();

	/* Initialize the vnode name cache. */
	nchinit();

#ifdef WAPBL
	wapbl_init();
#endif

	/*
	 * Stop using vfsconf and maxvfsconf as a temporary storage,
	 * set them to their correct values now.
	 */
	vfsconflist = vfsconf;
	vfsconflistlen = maxvfsconf;
	vfsconf = NULL;
	maxvfsconf = 0;

	for (i = 0; i < vfsconflistlen; i++)
		vfs_register(&vfsconflist[i]);
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:33,代码来源:vfs_init.c


示例20: test_single

// **TODO**: Add an test. This function shows only the usage of `append_cb`.
static char * test_single() {

	mpz_t a, b;
	mpz_array array1, array2, array_expect;
	mpz_pool pool;

	pool_init(&pool, 0);
	array_init(&array1, 3);
	array_init(&array2, 3);
	array_init(&array_expect, 3);

	// primes: 577, 727, 863
	mpz_init_set_str(a, "577", 10);
	array_add(&array_expect, a);
	mpz_set_str(a, "727", 10);
	array_add(&array_expect, a);
	mpz_set_str(a, "863", 10);
	array_add(&array_expect, a);

	// `a = 727 * 577 = 419479`
	// `b = 727 * 863 = 627401`
	mpz_set_str(a, "419479", 10);
	mpz_init_set_str(b, "627401", 10);

	append_cb(&pool, &array1, a, b);
	if (mpz_cmp_ui(a, 419479) != 0) {
		return "append_cb has changed the input value a!";
	}
	if (mpz_cmp_ui(b, 627401) != 0) {
		return "append_cb has changed the input value b!";
	}

	array_msort(&array1);
	if (!array_equal(&array_expect, &array1)) {
		return "array1 and array_expect differ!";
	}

	append_cb(&pool, &array2, b, a);
	if (mpz_cmp_ui(a, 419479) != 0) {
		return "append_cb has changed the input value a!";
	}
	if (mpz_cmp_ui(b, 627401) != 0) {
		return "append_cb has changed the input value b!";
	}

	array_msort(&array2);
	if (!array_equal(&array_expect, &array2)) {
		return "array2 and array_expect differ!";
	}

	mpz_clear(a);
	mpz_clear(b);
	array_clear(&array1);
	array_clear(&array2);
	array_clear(&array_expect);
	pool_clear(&pool);

	return 0;
}
开发者ID:unsecured,项目名称:copri,代码行数:60,代码来源:test-appendcb.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ popVar函数代码示例发布时间:2022-05-30
下一篇:
C++ pool_debug函数代码示例发布时间: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