]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/win32/service.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / common / win32 / service.h
1 /*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2019 SUSE LINUX GmbH
5 *
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
10 *
11 */
12
13 #include "include/compat.h"
14 #include "common/ceph_context.h"
15
16 class ServiceBase {
17
18 public:
19 ServiceBase(CephContext *cct_);
20 virtual ~ServiceBase() {};
21
22 static int initialize(ServiceBase *service);
23 protected:
24 static void run();
25 static void control_handler(DWORD request);
26
27 void shutdown(bool ignore_errors = false);
28 void stop();
29
30 void set_status(DWORD current_state, DWORD exit_code = NO_ERROR);
31
32 /* Subclasses should implement the following service hooks. */
33 virtual int run_hook() = 0;
34 /* Invoked when the service is requested to stop. */
35 virtual int stop_hook() = 0;
36 /* Invoked when the system is shutting down. */
37 virtual int shutdown_hook() = 0;
38
39 CephContext *cct;
40
41 private:
42 /* A handle used when reporting the current status. */
43 SERVICE_STATUS_HANDLE hstatus;
44 /* The current service status. */
45 SERVICE_STATUS status;
46
47 /* singleton service instance */
48 static ServiceBase *s_service;
49 };