Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / NT_Service / ntsvc.h
bloba7826d301ec222f0cbd1d7cfefc7c51e9ac506fd
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file ntsvc.h
7 * This is the definition of the sample NT Service class. This example
8 * only runs on Win32 platforms.
10 * @author Gonzalo Diethelm and Steve Huston
12 //=============================================================================
15 #ifndef NTSVC_H_
16 #define NTSVC_H_
18 #include "ace/config-lite.h"
20 #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES)
22 #include "ace/Event_Handler.h"
23 #include "ace/NT_Service.h"
24 #include "ace/Singleton.h"
25 #include "ace/Mutex.h"
27 class Service : public ACE_NT_Service
29 public:
30 Service ();
32 ~Service ();
34 /// We override <handle_control> because it handles stop requests
35 /// privately.
36 virtual void handle_control (DWORD control_code);
38 /// We override <handle_exception> so a 'stop' control code can pop
39 /// the reactor off of its wait.
40 virtual int handle_exception (ACE_HANDLE h);
42 /// This is a virtual method inherited from ACE_NT_Service.
43 virtual int svc ();
45 /// Where the real work is done:
46 virtual int handle_timeout (const ACE_Time_Value& tv,
47 const void *arg = 0);
49 private:
50 typedef ACE_NT_Service inherited;
52 private:
53 int stop_;
56 // Define a singleton class as a way to insure that there's only one
57 // Service instance in the program, and to protect against access from
58 // multiple threads. The first reference to it at runtime creates it,
59 // and the ACE_Object_Manager deletes it at run-down.
61 typedef ACE_Singleton<Service, ACE_Mutex> SERVICE;
63 #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */
65 #endif /* #ifndef NTSVC_H_ */