Provide the base class which defines the interface for controlling an NT service.
More...
Public Member Functions |
| ACE_NT_Service (DWORD start_timeout=ACE_NT_SERVICE_START_TIMEOUT, DWORD service_type=SERVICE_WIN32_OWN_PROCESS, DWORD controls_mask=SERVICE_ACCEPT_STOP) |
| Constructor primarily for use when running the service.
|
| ACE_NT_Service (const ACE_TCHAR *name, const ACE_TCHAR *desc=0, DWORD start_timeout=ACE_NT_SERVICE_START_TIMEOUT, DWORD service_type=SERVICE_WIN32_OWN_PROCESS, DWORD controls_mask=SERVICE_ACCEPT_STOP) |
virtual | ~ACE_NT_Service (void) |
virtual int | open (void *args=0) |
virtual int | fini (void) |
virtual int | svc (void) |
virtual void | handle_control (DWORD control_code) |
void | svc_handle (const SERVICE_STATUS_HANDLE new_svc_handle) |
void | name (const ACE_TCHAR *name, const ACE_TCHAR *desc=0) |
const ACE_TCHAR * | name (void) const |
| Get the service name.
|
const ACE_TCHAR * | desc (void) const |
| Get the service description.
|
void | host (const ACE_TCHAR *host) |
| Sets the host machine.
|
const ACE_TCHAR * | host (void) const |
| Get the host machine.
|
int | insert (DWORD start_type=SERVICE_DEMAND_START, DWORD error_control=SERVICE_ERROR_IGNORE, const ACE_TCHAR *exe_path=0, const ACE_TCHAR *group_name=0, LPDWORD tag_id=0, const ACE_TCHAR *dependencies=0, const ACE_TCHAR *account_name=0, const ACE_TCHAR *password=0, DWORD desired_access=SERVICE_ALL_ACCESS) |
int | remove (void) |
int | startup (DWORD startup) |
| Sets the startup type for the service. Returns -1 on error, 0 on success.
|
DWORD | startup (void) |
| Returns the current startup type.
|
void | capture_log_msg_attributes (void) |
void | inherit_log_msg_attributes (void) |
int | start_svc (ACE_Time_Value *wait_time=0, DWORD *svc_state=0, DWORD argc=0, const ACE_TCHAR **argv=0) |
int | stop_svc (ACE_Time_Value *wait_time=0, DWORD *svc_state=0) |
int | pause_svc (ACE_Time_Value *wait_time=0, DWORD *svc_state=0) |
| Pause the service.
|
int | continue_svc (ACE_Time_Value *wait_time=0, DWORD *svc_state=0) |
| Continue the service.
|
DWORD | state (ACE_Time_Value *wait_hint=0) |
int | state (DWORD *pstate, ACE_Time_Value *wait_hint=0) |
int | test_access (DWORD desired_access=SERVICE_ALL_ACCESS) |
| ACE_Task (ACE_Thread_Manager *thr_mgr=0, ACE_Message_Queue< ACE_SYNCH_USE, ACE_System_Time_Policy > *mq=0) |
virtual | ~ACE_Task (void) |
| Destructor.
|
ACE_Message_Queue
< ACE_SYNCH_USE,
ACE_System_Time_Policy > * | msg_queue (void) |
| Gets the message queue associated with this task.
|
void | msg_queue (ACE_Message_Queue< ACE_SYNCH_USE, ACE_System_Time_Policy > *) |
| Sets the message queue associated with this task.
|
ACE_Time_Value_T
< ACE_System_Time_Policy > | gettimeofday (void) const |
void | set_time_policy (ACE_System_Time_Policyconst &time_policy) |
int | putq (ACE_Message_Block *, ACE_Time_Value *timeout=0) |
int | getq (ACE_Message_Block *&mb, ACE_Time_Value *timeout=0) |
int | ungetq (ACE_Message_Block *, ACE_Time_Value *timeout=0) |
int | reply (ACE_Message_Block *mb, ACE_Time_Value *tv=0) |
int | put_next (ACE_Message_Block *msg, ACE_Time_Value *timeout=0) |
ACE_Task< ACE_SYNCH_USE,
ACE_System_Time_Policy > * | next (void) |
| Get next Task pointer.
|
void | next (ACE_Task< ACE_SYNCH_USE, ACE_System_Time_Policy > *) |
| Set next Task pointer.
|
ACE_Task< ACE_SYNCH_USE,
ACE_System_Time_Policy > * | sibling (void) |
ACE_Module< ACE_SYNCH_USE,
ACE_System_Time_Policy > * | module (void) const |
| Return the Task's Module if there is one, else returns 0.
|
int | flush (u_long flag=ACE_Task_Flags::ACE_FLUSHALL) |
void | water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t) |
| Manipulate watermarks.
|
void | dump (void) const |
| Dump the state of an object.
|
| ACE_Task_Base (ACE_Thread_Manager *=0) |
| Constructor.
|
virtual | ~ACE_Task_Base (void) |
| Destructor.
|
virtual int | close (u_long flags=0) |
| Default ACE_Task close routine.
|
virtual int | module_closed (void) |
virtual int | put (ACE_Message_Block *, ACE_Time_Value *=0) |
| Default ACE_Task put routine.
|
virtual int | activate (long flags=THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_ids[]=0, const char *thr_name[]=0) |
virtual int | wait (void) |
| Wait for all threads running in a task to exit.
|
virtual int | suspend (void) |
| Suspend a task.
|
virtual int | resume (void) |
| Resume a suspended task.
|
int | grp_id (void) const |
| Get the current group id.
|
void | grp_id (int) |
| Set the current group id.
|
ACE_Thread_Manager * | thr_mgr (void) const |
| Get the thread manager associated with this Task.
|
void | thr_mgr (ACE_Thread_Manager *) |
| Set the thread manager associated with this Task.
|
int | is_reader (void) const |
| True if queue is a reader, else false.
|
int | is_writer (void) const |
| True if queue is a writer, else false.
|
size_t | thr_count (void) const |
ACE_thread_t | last_thread (void) const |
| ACE_Service_Object (ACE_Reactor *=0) |
| Constructor.
|
virtual | ~ACE_Service_Object (void) |
| Destructor.
|
virtual | ~ACE_Event_Handler (void) |
| Destructor is virtual to enable proper cleanup.
|
virtual ACE_HANDLE | get_handle (void) const |
| Get the I/O handle.
|
virtual void | set_handle (ACE_HANDLE) |
| Set the I/O handle.
|
virtual int | priority (void) const |
virtual void | priority (int priority) |
| Set the priority of the Event_Handler.
|
virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when input events occur (e.g., connection or data).
|
virtual int | handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
virtual int | handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when an exceptional events occur (e.g., SIGURG).
|
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
virtual int | handle_exit (ACE_Process *) |
| Called when a process exits.
|
virtual int | handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) |
virtual int | handle_signal (int signum, siginfo_t *=0, ucontext_t *=0) |
virtual int | resume_handler (void) |
virtual int | handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual int | handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual void | reactor (ACE_Reactor *reactor) |
| Set the event demultiplexors.
|
virtual ACE_Reactor * | reactor (void) const |
| Get the event demultiplexors.
|
virtual
ACE_Reactor_Timer_Interface * | reactor_timer_interface (void) const |
| Get only the reactor's timer related interface.
|
virtual Reference_Count | add_reference (void) |
| Increment reference count on the handler.
|
virtual Reference_Count | remove_reference (void) |
| Decrement reference count on the handler.
|
Reference_Counting_Policy & | reference_counting_policy (void) |
| Current Reference_Counting_Policy.
|
| ACE_Shared_Object (void) |
| Constructor.
|
virtual | ~ACE_Shared_Object (void) |
| Destructor.
|
virtual int | init (int argc, ACE_TCHAR *argv[]) |
| Initializes object when dynamic linking occurs.
|
virtual int | info (ACE_TCHAR **info_string, size_t length=0) const |
| Returns information on a service object.
|
Provide the base class which defines the interface for controlling an NT service.
NT Services can be implemented using the framework defined by the ACE_NT_Service class, and the macros defined in this file. Some quick refresher notes on NT Services:
- The main program defines an array of entries describing the services offered. The ACE_NT_SERVICE_ENTRY macro can help with this.
- For each service, a separate ServiceMain and Handler function need to be defined. These are taken care of by the ACE_NT_SERVICE_DEFINE macro.
- When the main program/thread calls StartServiceCtrlDispatcher, NT creates a thread for each service, and runs the ServiceMain function for the service in that new thread. When that thread exits, the service is gone.
To use this facility, you could derive a class from ACE_Service_Object (if you want to start via ACE's service configurator), or use any other class to run when the image starts (assuming that NT runs the image). You must set up an NT SERVICE_TABLE_ENTRY array to define your service(s). You can use the ACE_NT_SERVICE_... macros defined below for this.
A SERVICE_TABLE might look like this: ACE_NT_SERVICE_REFERENCE(Svc1); // If service is in another file SERVICE_TABLE_ENTRY myServices[] = { ACE_NT_SERVICE_ENTRY ("MyNeatService", Svc1), { 0, 0 } };
In the file where your service(s) are implemented, use the ACE_NT_SERVICE_DEFINE macro to set up the following:
- A pointer to the service's implementation object (must be derived from ACE_NT_Service).
- The service's Handler function (forwards all requests to the ACE_NT_Service-derived object's handle_control function).
- The service's ServiceMain function. Creates a new instance of the ACE_NT_Service-derived class SVCCLASS, unless one has been created already.
If you are using all the default constructor values, you can let the generated ServiceMain function create the object, else you need to create it by hand before calling StartServiceCtrlDispatcher. Set the pointer so ServiceMain won't create another one. Another reason you may want to do the object creation yourself is if you want to also implement suspend and resume functions (the ones inherited from ACE_Service_Object) to do something intelligent to the services which are running, like call their handle_control functions to request suspend and resume actions, similar to what NT would do if a Services control panel applet would do if the user clicks on Suspend.