int main (int argc, char** argv) { uthread_t t[4]; uthread_init (4); // TODO: Create Threads and Join struct Pool* p = createPool(); for (int i = 0; i < NUM_PRODUCERS; i++) { t[i] = uthread_create(producer,p); } for (int j = NUM_PRODUCERS; j < NUM_PRODUCERS + NUM_CONSUMERS; j++) { t[j] = uthread_create(consumer,p); } for (int z = 0; z < NUM_PRODUCERS + NUM_CONSUMERS; z++) { uthread_join(t[z], NULL); } printf ("producer_wait_count=%d, consumer_wait_count=%d\n", producer_wait_count, consumer_wait_count); printf ("items value histogram:\n"); int sum=0; for (int i = 0; i <= MAX_ITEMS; i++) { printf (" items=%d, %d times\n", i, histogram [i]); sum += histogram [i]; } assert (sum == sizeof (t) / sizeof (uthread_t) * NUM_ITERATIONS); }
StorageDistributedDirectoryMonitor::StorageDistributedDirectoryMonitor(StorageDistributed & storage, const std::string & name) : storage(storage), pool{createPool(name)}, path{storage.path + name + '/'} , default_sleep_time{storage.context.getSettingsRef().distributed_directory_monitor_sleep_time_ms.totalMilliseconds()} , sleep_time{default_sleep_time} , log{&Logger::get(getLoggerName())} { }
int main(int argc, char** argv) { int i; ThreadPool* pool = createPool(5); // Intentionally ignoring the CORE * 2 + 1 rule. Task task2[10]; for(i = 0; i < 10; ++i) { task2[i].deadline = DONTCARE; task2[i].runnable = &starve; addTask(pool, &task2[i]); } Task task[2]; for(i = 0; i < 2; ++i) { task[i].deadline = 4; // in seconds. task[i].runnable = &echoTest; addTask(pool, &task[i]); } joinThreadPool(pool); free(pool); return 0; }
MongoDBConnectionPool::MongoDBConnectionPool(const ConnectionProperties& props) { logger = LoggerFactory::getLogger("SQLConnectionPool"); std::map<std::string, std::string> mp = props.getProperties(); isReplicaSet = StringUtil::toLowerCopy(mp["isReplicaSet"])=="true"; isSSL = StringUtil::toLowerCopy(mp["isSSL"])=="true"; isUnixDomainSocket = StringUtil::toLowerCopy(mp["isUnixDomainSocket"])=="true"; isSharded = StringUtil::toLowerCopy(mp["isSharded"])=="true"; replicaSetName = mp["replicaName"]; createPool(props); }
static void run() { pool_ut ut; g_pool = createPool(); g_parser = createDynamicParser(); g_parser->init("../../common/material/entity"); PoolCfgx cfg; cfg.logger = LoggerFactory::createFileLogger("test.log"); cfg.handle_output = std::bind(&pool_ut::output, &ut, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); g_pool->init(cfg); g_cache = CacheFactory::createManageCache(1); CacheCfg cache_cfg; cache_cfg.handle_input = &ut; cache_cfg.network_thread_no = 1; cache_cfg.local_path = "d:/temp"; cache_cfg.remote_cfg.cache_addrs.push_back("127.0.0.1:13000"); cache_cfg.remote_cfg.type = 1; if (-1 == g_cache->init(cache_cfg)) { printf("failed to init cache !\n"); g_cache->stop(); g_cache->finit(); return; } uint64 player_guid = 1; DECLARE_REQUEST_LIST(g_pool); LOAD_ONCE_REQUEST(1, 2, const_cast<MSG_TYPE *>(g_parser->GetPrototype("test"))); POOL_OP_COMMIT(g_pool, boost::bind(&pool_ut::loadPlayerFinish, &ut, _1, player_guid)); while (true) { ACE_OS::sleep(1); } }
/*static CibernateConnectionPool *instance = NULL; CibernateConnectionPool* CibernateConnectionPool::getinstance() { if(this==NULL) instance = new CibernateConnectionPool; return instance; }*/ CibernateConnectionPool::CibernateConnectionPool(int size,string dbName,string uname,string pass) { logger = Logger::getLogger("CibernateConnectionPool"); createPool(size,dbName,uname,pass); }