Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / APG / ThreadManagement / Pool.cpp
blobee4d4556b1e3f621675660306ccced984253c01e
1 #include "ace/config-lite.h"
2 #if defined (ACE_HAS_THREADS)
4 #include "ace/Task.h"
5 #include "ace/Log_Msg.h"
7 // Listing 1 code/ch13
8 class HA_CommandHandler : public ACE_Task<ACE_MT_SYNCH>
10 public:
11 virtual int svc ()
13 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) starting up\n")));
14 ACE_Message_Block *mb = 0;
15 if (this->getq (mb) == -1)
16 return -1;
17 // ... do something with the message.
18 return 0;
21 // Listing 1
22 // Listing 2 code/ch13
23 int ACE_TMAIN (int, ACE_TCHAR *[])
25 HA_CommandHandler handler;
27 // Create 4 threads.
28 handler.activate (THR_NEW_LWP | THR_JOINABLE, 4);
29 handler.wait ();
30 return 0;
32 // Listing 2
34 #else
35 #include "ace/OS_main.h"
36 #include "ace/OS_NS_stdio.h"
38 int ACE_TMAIN (int, ACE_TCHAR *[])
40 ACE_OS::puts (ACE_TEXT ("This example requires threads."));
41 return 0;
44 #endif /* ACE_HAS_THREADS */