blob: c6750e6f38fcf2cff61be589cf7de786d1840544 [file] [log] [blame]
Eddie James18e1e462018-12-11 13:24:36 -06001#pragma once
2
3#include "ikvm_args.hpp"
4#include "ikvm_input.hpp"
5#include "ikvm_server.hpp"
6#include "ikvm_video.hpp"
7
8#include <condition_variable>
9#include <mutex>
10
11namespace ikvm
12{
Eddie James18e1e462018-12-11 13:24:36 -060013/*
14 * @class Manager
15 * @brief Manages the VNC server by executing threaded loops of RFB operations
16 * and video device operations.
17 */
18class Manager
19{
20 public:
21 /*
22 * @brief Constructs the Manager object
23 *
24 * @param[in] args - Reference to Args object
25 */
26 Manager(const Args& args);
27 ~Manager() = default;
28 Manager(const Manager&) = default;
29 Manager& operator=(const Manager&) = default;
30 Manager(Manager&&) = default;
31 Manager& operator=(Manager&&) = default;
32
33 /* @brief Begins operation of the VNC server */
34 void run();
35
36 private:
37 /*
38 * @brief Thread function to loop the RFB update operations
39 *
40 * @param[in] manager - Pointer to the Manager object
41 */
42 static void serverThread(Manager* manager);
43
44 /* @brief Notifies thread waiters that RFB operations are complete */
45 void setServerDone();
46 /* @brief Notifies thread waiters that video operations are complete */
47 void setVideoDone();
48 /* @brief Blocks until RFB operations complete */
49 void waitServer();
50 /* @brief Blocks until video operations are complete */
51 void waitVideo();
52
53 /*
54 * @brief Boolean to indicate whether the application should continue
55 * running
56 */
57 bool continueExecuting;
58 /* @brief Boolean to indicate that RFB operations are complete */
59 bool serverDone;
60 /* @brief Boolean to indicate that video operations are complete */
61 bool videoDone;
62 /* @brief Input object */
63 Input input;
64 /* @brief Video object */
65 Video video;
66 /* @brief RFB server object */
67 Server server;
68 /* @brief Condition variable to enable waiting for thread completion */
69 std::condition_variable sync;
70 /* @brief Mutex for waiting on condition variable safely */
71 std::mutex lock;
72};
73
74} // namespace ikvm