![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2009
Posts: 2
OS: Windows XP
|
Creating Thread pool using ACE Programming
I created a simple thread pool using ACE classes. The code is provided below. It breaks.
//=========================================================== // Sample Thread Pool // //=========================================================== #include "ace/OS_main.h" #include "ace/Task.h" #include <iostream> using namespace std; class HA_CommandHandler: public ACE_Task<ACE_MT_SYNCH> { public: virtual int svc() { cout << "Starting" << endl; ACE_DEBUG((LM_DEBUG, "(%t) starting up \n")); ACE_Message_Block *mb; int result = this->getq(mb); //... do something with the message. return 0; } }; int main(int argc, char *argv[]) { cout << "In Main" << endl; printf("In Main"); cout.flush(); HA_CommandHandler handler; handler.activate( THR_NEW_LWP | THR_JOINABLE, 4); create 4 threads handler.wait(); return 0; } -------------------------------------------------------------------------- The moment I create an object of HA_CommandHandler in main, I can't print any output. cout << "In Main" << endl; doesn't print. There are no compiler issues $ make make[1]: Entering directory `/cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool' GNUmakefile: /cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool/GNUmakefile.sThreadPool MA KEFLAGS=w g++ -Wpointer-arith -mthreads -mtune=pentiumpro -O3 -g -pipe -pipe -I/cygdrive/c/ACE-5. 7.0/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -c -o .obj/sThreadPool.o sThread Pool.cpp g++ -Wpointer-arith -mthreads -mtune=pentiumpro -O3 -g -pipe -pipe -I/cygdrive/c/ACE-5. 7.0/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -Wl,--enable-auto-import -Wl,-E -L/cygdrive/c/ACE-5.7.0/ACE_wrappers/lib -L. -L../lib -o sThreadPool.exe .obj/sThreadPool.o -lACE make[1]: Leaving directory `/cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool' sathaval@HYDB1L2-039 /cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool $ ./sThreadPool.exe The program works fine when I comment the object creation. /*HA_CommandHandler handler; handler.activate( THR_NEW_LWP | THR_JOINABLE, 4); create 4 threads handler.wait();*/ ------------------------------------------------------------------------ $ make make[1]: Entering directory `/cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool' GNUmakefile: /cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool/GNUmakefile.sThreadPool MA KEFLAGS=w g++ -Wpointer-arith -mthreads -mtune=pentiumpro -O3 -g -pipe -pipe -I/cygdrive/c/ACE-5. 7.0/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -c -o .obj/sThreadPool.o sThread Pool.cpp g++ -Wpointer-arith -mthreads -mtune=pentiumpro -O3 -g -pipe -pipe -I/cygdrive/c/ACE-5. 7.0/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -Wl,--enable-auto-import -Wl,-E -L/cygdrive/c/ACE-5.7.0/ACE_wrappers/lib -L. -L../lib -o sThreadPool.exe .obj/sThreadPool.o -lACE make[1]: Leaving directory `/cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool' sathaval@HYDB1L2-039 /cygdrive/c/ACE-5.7.0/ACE_wrappers/tests/SThreadPool $ ./sThreadPool.exe In Main In Main -------------------------------------------------------------------------- |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
![]() |
| Thread Tools | |
|
|