Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / ThreadManagement / Start_Hook.cpp
blob805e81435f54814d79f2ba111d9acf97ac3c0514
1 #include "ace/Thread_Hook.h"
2 #include "ace/Task.h"
3 #include "ace/Log_Msg.h"
5 #include "SecurityContext.h"
7 // Listing 1 code/ch13
8 class HA_ThreadHook : public ACE_Thread_Hook
10 public:
11 virtual ACE_THR_FUNC_RETURN start (ACE_THR_FUNC func, void* arg)
13 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("(%t) New Thread Spawned\n")));
15 // Create the context on the thread's own stack.
16 ACE_TSS<SecurityContext> secCtx;
17 // Special initialization.
18 add_sec_context_thr (secCtx);
20 return (*func) (arg);
23 void add_sec_context_thr (ACE_TSS<SecurityContext> &secCtx);
25 // Listing 1
27 void
28 HA_ThreadHook::add_sec_context_thr(ACE_TSS<SecurityContext> &secCtx)
30 secCtx->user = 0;
34 class HA_CommandHandler : public ACE_Task_Base
36 public:
37 virtual int svc ()
39 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) starting up\n")));
41 // Do something.
43 return 0;
46 // Listing 2 code/ch13
47 int ACE_TMAIN (int, ACE_TCHAR *[])
49 HA_ThreadHook hook;
50 ACE_Thread_Hook::thread_hook (&hook);
52 HA_CommandHandler handler;
53 handler.activate ();
54 handler.wait();
55 return 0;
57 // Listing 2