![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BdbClusteringServer/testBdbThreadPool.cc
Go to the documentation of this file.00001 00002 00003 #include "BdbClusteringServer/BdbThreadPool.hh" 00004 #include "BdbClusteringServer/BdbSrvLogMgr.hh" 00005 #include "BdbClusteringServer/BdbSrvUtil.hh" 00006 #include <iostream.h> 00007 #include <assert.h> 00008 00009 void* fun(void*) 00010 {return 0; 00011 00012 } 00013 00014 int main(int, char**) 00015 { 00016 BdbSrvUtil::_logDir = "/tmp"; 00017 00018 BdbSrvLogMgr::openLogFiles(); 00019 00020 BdbThreadPool tp; 00021 tp.print(); 00022 pthread_t* t1 = tp.assignIdleThread("one"); 00023 pthread_create(t1, 0, fun, 0); 00024 tp.print(); 00025 pthread_t* t2 = tp.assignIdleThread("two"); 00026 tp.print(); 00027 pthread_t* t3 = tp.assignIdleThread("three"); 00028 tp.print(); 00029 pthread_t* p = tp.findThread("two"); 00030 cout << "looked for two, got " << *p << endl; 00031 p = tp.findThread("weird"); 00032 if ( p==0) { 00033 cout << "ok, weird not found" << endl; 00034 } else { 00035 assert(0); 00036 } 00037 tp.print(); 00038 tp.releaseThread(*t1); 00039 tp.print(); 00040 tp.releaseThread(*t3); 00041 tp.print(); 00042 tp.releaseThread(0); 00043 tp.print(); 00044 tp.releaseThread(*t2); 00045 tp.print(); 00046 pthread_t* t4 = tp.assignIdleThread("four"); 00047 tp.print(); 00048 return 0; 00049 }
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002