1 #include "ace/config-lite.h"
2 #if defined (ACE_HAS_THREADS)
6 #include "ClientContext.h"
10 ClientContext::get_attribute (const char *name
)
13 attributeMap_
.find (name
, value
);
18 ClientContext::set_attribute (const char *name
, void *value
)
20 attributeMap_
.bind (name
, value
);
23 // Listing 2 code/ch14
24 class HA_CommandHandler
: public ACE_Task
<ACE_MT_SYNCH
>
29 ACE_thread_t tid
= this->thr_mgr ()->thr_self ();
30 // Set our identifier in TSS.
31 this->tss_ctx_
->set_attribute ("thread_id", &tid
);
33 while (handle_requests () > 0)
39 int handle_requests ()
42 (ACE_thread_t
*)this->tss_ctx_
->get_attribute ("thread_id");
43 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("(%t) TSS TID: %d\n"),
51 ACE_TSS
<ClientContext
> tss_ctx_
;
55 int ACE_TMAIN (int, ACE_TCHAR
*[])
57 HA_CommandHandler handler
;
58 handler
.activate (THR_NEW_LWP
| THR_JOINABLE
, 5);
64 #include "ace/OS_main.h"
65 #include "ace/OS_NS_stdio.h"
67 int ACE_TMAIN (int, ACE_TCHAR
*[])
69 ACE_OS::puts (ACE_TEXT ("This example requires threads."));
73 #endif /* ACE_HAS_THREADS */