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