summaryrefslogtreecommitdiffstats
path: root/ikvm_manager.hpp
blob: 67d5a681e62320d6c3a01435657b31ebbeee8acf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once

#include "ikvm_args.hpp"
#include "ikvm_input.hpp"
#include "ikvm_server.hpp"
#include "ikvm_video.hpp"

#include <condition_variable>
#include <mutex>

namespace ikvm
{

/*
 * @class Manager
 * @brief Manages the VNC server by executing threaded loops of RFB operations
 *        and video device operations.
 */
class Manager
{
  public:
    /*
     * @brief Constructs the Manager object
     *
     * @param[in] args - Reference to Args object
     */
    Manager(const Args& args);
    ~Manager() = default;
    Manager(const Manager&) = default;
    Manager& operator=(const Manager&) = default;
    Manager(Manager&&) = default;
    Manager& operator=(Manager&&) = default;

    /* @brief Begins operation of the VNC server */
    void run();

  private:
    /*
     * @brief Thread function to loop the RFB update operations
     *
     * @param[in] manager - Pointer to the Manager object
     */
    static void serverThread(Manager* manager);

    /* @brief Notifies thread waiters that RFB operations are complete */
    void setServerDone();
    /* @brief Notifies thread waiters that video operations are complete */
    void setVideoDone();
    /* @brief Blocks until RFB operations complete */
    void waitServer();
    /* @brief Blocks until video operations are complete */
    void waitVideo();

    /*
     * @brief Boolean to indicate whether the application should continue
     *        running
     */
    bool continueExecuting;
    /* @brief Boolean to indicate that RFB operations are complete */
    bool serverDone;
    /* @brief Boolean to indicate that video operations are complete */
    bool videoDone;
    /* @brief Input object */
    Input input;
    /* @brief Video object */
    Video video;
    /* @brief RFB server object */
    Server server;
    /* @brief Condition variable to enable waiting for thread completion */
    std::condition_variable sync;
    /* @brief Mutex for waiting on condition variable safely */
    std::mutex lock;
};

} // namespace ikvm
OpenPOWER on IntegriCloud