1 #include "ace/config-lite.h"
2 #if defined (ACE_HAS_THREADS)
8 class HA_Device_Repository
11 HA_Device_Repository ()
14 void update_device (int device_id
)
17 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("(%t) Updating device %d\n"),
24 ACE_Thread_Mutex mutex_
;
27 // Listing 2 code/ch12
28 class HA_CommandHandler
: public ACE_Task_Base
33 HA_CommandHandler (HA_Device_Repository
& rep
) : rep_(rep
)
39 ((LM_DEBUG
, ACE_TEXT ("(%t) Handler Thread running\n")));
40 for (int i
=0; i
< NUM_USES
; i
++)
41 this->rep_
.update_device (i
);
46 HA_Device_Repository
& rep_
;
49 int ACE_TMAIN (int, ACE_TCHAR
*[])
51 HA_Device_Repository rep
;
52 HA_CommandHandler
handler1 (rep
);
53 HA_CommandHandler
handler2 (rep
);
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 */