void CSecureHttpProtocol::init(IPropertyTree * cfg, const char * process, const char * protocol) { Owned<IPropertyTree> proc_cfg = getProcessConfig(cfg, process); if (proc_cfg) { CEspProtocol::setViewConfig(proc_cfg->getPropBool("@httpConfigAccess")); const char* mctstr = proc_cfg->queryProp("@maxConcurrentThreads"); if(mctstr && *mctstr) { m_maxConcurrentThreads = atoi(mctstr); } if(m_maxConcurrentThreads > 0) { // Could use a mutex, but since all the protocols are instantiated sequentially, not really necessary if(!http_pool_factory) http_pool_factory = new CHttpThreadPoolFactory(); if(!http_thread_pool) http_thread_pool = createThreadPool("Http Thread", http_pool_factory, NULL, m_maxConcurrentThreads, INFINITE); } } initPersistentHandler(proc_cfg); Owned<IPropertyTree> proto_cfg = getProtocolConfig(cfg, protocol, process); if(proto_cfg) { const char* lenstr = proto_cfg->queryProp("@maxRequestEntityLength"); if(lenstr && *lenstr) { setMaxRequestEntityLength(atoi(lenstr)); } } }
CMessageHandler(const char *_name,PARENT *_parent,void (PARENT::*_handler)(CMessageBuffer &_mb), IExceptionHandler *exceptionHandler=NULL, unsigned maxthreads=40, unsigned timeoutOnRelease=INFINITE, unsigned lowThreadsDelay=1000) { parent = _parent; handler = _handler; name = strdup(_name); pool = createThreadPool(name,this,exceptionHandler,maxthreads,lowThreadsDelay,0,timeoutOnRelease); // this will cause this to be linked hasexceptionhandler = exceptionHandler!=NULL; }
int main() { pthread_mutex_init(&lineMutex,NULL); // find("/home/zgh/submit/test"); // find("/usr/include"); createThreadPool(2); // addTask("/home/zgh/submit/test"); addTask("/usr/include"); sleep(3); printf("%d\n",lineCount); return 0; }
void * fthSchedPthread(void *arg) { // get the fthread engine going waitee.waitType = PTOF_WAIT; waitee.wu.ptof = mbox; test_rock = 1; pool = createThreadPool(test_fn, test_rock, &waitee, NUM_THREADS, STACK_SIZE); printf("Got the new threadPool %p\n", pool); sem_post(&general_sem); printf("Posted the semaphore\n", pool); fthSchedulerPthread(0); printf("Scheduler halted\n"); return NULL; }
bool CppCompiler::compile() { if (abortChecker && abortChecker->abortRequested()) return false; TIME_SECTION(!verbose ? NULL : onlyCompile ? "compile" : "compile/link"); Owned<IThreadPool> pool = createThreadPool("CCompilerWorker", this, NULL, maxCompileThreads?maxCompileThreads:1, INFINITE); addCompileOption(COMPILE_ONLY[targetCompiler]); bool ret = false; Semaphore finishedCompiling; int numSubmitted = 0; numFailed.store(0); ForEachItemIn(i0, allSources) { ret = compileFile(pool, allSources.item(i0), finishedCompiling); if (!ret) break; ++numSubmitted; }