VirtualBox

source: vbox/trunk/src/VBox/Main/include/ClientWatcher.h@ 48112

Last change on this file since 48112 was 47561, checked in by vboxsync, 11 years ago

Main/VirtualBox+Machine+Session: separate out the client death detection functionality into separate objects

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: ClientWatcher.h 47561 2013-08-06 15:18:17Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox API client watcher
6 */
7
8/*
9 * Copyright (C) 2013 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef ____H_CLIENTWATCHER
21#define ____H_CLIENTWATCHER
22
23#include <list>
24#include <VBox/com/ptr.h>
25#include <VBox/com/AutoLock.h>
26
27#include "VirtualBoxImpl.h"
28
29#if defined(RT_OS_WINDOWS)
30# define CWUPDATEREQARG NULL
31# define CWUPDATEREQTYPE HANDLE
32#elif defined(RT_OS_OS2)
33# define CWUPDATEREQARG NIL_RTSEMEVENT
34# define CWUPDATEREQTYPE RTSEMEVENT
35#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
36# define CWUPDATEREQARG
37# define CWUPDATEREQTYPE RTSEMEVENT
38#else
39# error "Port me!"
40#endif
41
42/**
43 * Class which checks for API clients which have crashed/exited, and takes
44 * the necessary cleanup actions. Singleton.
45 */
46class VirtualBox::ClientWatcher
47{
48public:
49 /**
50 * Constructor which creates a usable instance
51 *
52 * @param pVirtualBox Reference to VirtualBox object
53 */
54 ClientWatcher(const ComObjPtr<VirtualBox> &pVirtualBox);
55
56 /**
57 * Default destructor. Cleans everything up.
58 */
59 ~ClientWatcher();
60
61 bool isReady();
62
63 void update();
64 void addProcess(RTPROCESS pid);
65
66private:
67 /**
68 * Default constructor. Don't use, will not create a sensible instance.
69 */
70 ClientWatcher();
71
72 static DECLCALLBACK(int) worker(RTTHREAD /* thread */, void *pvUser);
73
74 VirtualBox *mVirtualBox;
75 RTTHREAD mThread;
76 CWUPDATEREQTYPE mUpdateReq;
77 util::RWLockHandle mLock;
78
79 typedef std::list<RTPROCESS> ProcessList;
80 ProcessList mProcesses;
81
82#ifdef VBOX_WITH_SYS_V_IPC_SESSION_WATCHER
83 uint8_t mUpdateAdaptCtr;
84#endif
85};
86
87#endif /* !____H_CLIENTWATCHER */
88/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette