-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpfaces-agent.h
64 lines (51 loc) · 2.12 KB
/
pfaces-agent.h
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
#ifndef PFACES_AGENT_H
#define PFACES_AGENT_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "pfacesRemoteInterface.h"
#include "pfaces-agent-helper.h"
enum class LaunchModes {
RUN,
INSTALL,
UNINSTALL,
};
// pFacesAgent class
// =================
// pFacesAgent is responsible for launching pFaces according to different scenarios
// the service/daemon will firs tinitiate at least one pFacesAgent object
// each pFacesAgent object should be associated to one unique port which it will listen to.
// the run function of the pFacesAgent will be continously called by the service/daemon with some time gab in betwwen
// the servant should not mae "run" blocking.
// The agent assumes its unique possition of the resources it is assigned to using the device_mask/device_ids_list.
// The agent is responsible for scheduling betweeen different requests competing on its resources.
// The agent may help synchronize data with other agents.
class pFacesAgent {
std::shared_ptr<pFacesAgent> spThis;
public:
AgentConfigs m_configs;
// the dictionary severs
std::shared_ptr<pfacesRESTfullDictionaryServer> LoginDictionaryServer;
std::vector<std::shared_ptr<pfacesRESTfullDictionaryServer>> userDictionaryServers;
// active serving threads
std::shared_ptr<std::thread> loginManagerThread;
std::vector<std::shared_ptr<std::thread>> userManagerThreads;
// kill signal for all threads
std::shared_ptr<std::mutex> sp_kill_signal_mutex;
bool kill_signal = false;
// last assigned port
size_t last_assigned_port;
pFacesAgent(const AgentConfigs& configs);
~pFacesAgent() = default;
// run will be called often from the service/daemon and should not be blocking
// it should sense the port and read any requests, then, launch pFaces with it.
// upon launchin a new pFaces job, it should store the lauch settings and track pFaaces.
// It may decide to delay another launch of pFAces if oneis already running in the devices
// assicliated
int run();
int kill();
bool initializeLoginDictionary();
};
#endif // ! PFACES_AGENT_H