summaryrefslogtreecommitdiff
path: root/ACE/examples/NT_Service/ntsvc.h
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/examples/NT_Service/ntsvc.h')
-rw-r--r--ACE/examples/NT_Service/ntsvc.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/ACE/examples/NT_Service/ntsvc.h b/ACE/examples/NT_Service/ntsvc.h
new file mode 100644
index 00000000000..cecc91b34c5
--- /dev/null
+++ b/ACE/examples/NT_Service/ntsvc.h
@@ -0,0 +1,65 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// examples/NT_Service
+//
+// = FILENAME
+// ntsvc.h
+//
+// = DESCRIPTION
+// This is the definition of the sample NT Service class. This example
+// only runs on Win32 platforms.
+//
+// = AUTHOR
+// Gonzalo Diethelm and Steve Huston
+//
+// ============================================================================
+
+#ifndef NTSVC_H_
+#define NTSVC_H_
+
+#include "ace/Event_Handler.h"
+#include "ace/NT_Service.h"
+#include "ace/Singleton.h"
+#include "ace/Mutex.h"
+
+class Service : public ACE_NT_Service
+{
+public:
+ Service (void);
+
+ ~Service (void);
+
+ virtual void handle_control (DWORD control_code);
+ // We override <handle_control> because it handles stop requests
+ // privately.
+
+ virtual int handle_exception (ACE_HANDLE h);
+ // We override <handle_exception> so a 'stop' control code can pop
+ // the reactor off of its wait.
+
+ virtual int svc (void);
+ // This is a virtual method inherited from ACE_NT_Service.
+
+ virtual int handle_timeout (const ACE_Time_Value& tv,
+ const void *arg = 0);
+ // Where the real work is done:
+
+private:
+ typedef ACE_NT_Service inherited;
+
+private:
+ int stop_;
+};
+
+// Define a singleton class as a way to insure that there's only one
+// Service instance in the program, and to protect against access from
+// multiple threads. The first reference to it at runtime creates it,
+// and the ACE_Object_Manager deletes it at run-down.
+
+typedef ACE_Singleton<Service, ACE_Mutex> SERVICE;
+
+#endif /* #ifndef NTSVC_H_ */