Fixed server
This commit is contained in:
parent
98eab49e99
commit
b171906162
4 changed files with 32 additions and 4 deletions
|
|
@ -99,8 +99,8 @@ public:
|
|||
protected:
|
||||
std::string host;
|
||||
unsigned short port_num;
|
||||
bool server_online;
|
||||
bool server_listening;
|
||||
std::atomic<bool> server_online;
|
||||
std::atomic<bool> server_listening;
|
||||
|
||||
std::vector<RGBController *>& controllers;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ ResourceManager::ResourceManager()
|
|||
InitThread = nullptr;
|
||||
DetectDevicesThread = nullptr;
|
||||
dynamic_detectors_processed = false;
|
||||
init_finished = false;
|
||||
|
||||
SetupConfigurationDirectory();
|
||||
|
||||
|
|
@ -1632,6 +1633,8 @@ void ResourceManager::InitThreadFunction()
|
|||
{
|
||||
cli_post_detection();
|
||||
}
|
||||
|
||||
init_finished = true;
|
||||
}
|
||||
|
||||
void ResourceManager::UpdateDetectorSettings()
|
||||
|
|
@ -1735,6 +1738,19 @@ void ResourceManager::UpdateDetectorSettings()
|
|||
}
|
||||
}
|
||||
|
||||
void ResourceManager::WaitForInitialization()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| A reliable sychronization of this kind is |
|
||||
| impossible without the use of a `barrier` |
|
||||
| implementation, which is only introduced in C++20 |
|
||||
\*-------------------------------------------------*/
|
||||
while (!init_finished)
|
||||
{
|
||||
std::this_thread::sleep_for(1ms);
|
||||
};
|
||||
}
|
||||
|
||||
void ResourceManager::WaitForDeviceDetection()
|
||||
{
|
||||
DetectDeviceMutex.lock();
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ public:
|
|||
|
||||
void StopDeviceDetection();
|
||||
|
||||
void WaitForInitialization();
|
||||
void WaitForDeviceDetection();
|
||||
|
||||
private:
|
||||
|
|
@ -243,6 +244,10 @@ private:
|
|||
| Auto connection permitting flag |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
bool apply_post_options;
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Initialization completion flag |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::atomic<bool> init_finished;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Profile Manager |
|
||||
|
|
|
|||
11
main.cpp
11
main.cpp
|
|
@ -253,7 +253,14 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if(ret_flags & RET_FLAG_START_SERVER)
|
||||
{
|
||||
if(!ResourceManager::get()->GetServer()->GetOnline())
|
||||
NetworkServer* server = ResourceManager::get()->GetServer();
|
||||
ResourceManager::get()->WaitForInitialization();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| The server is only started after detection finishes and |
|
||||
| it takes some time to get the server online - we wait |
|
||||
\*---------------------------------------------------------*/
|
||||
if(!server->GetOnline())
|
||||
{
|
||||
#ifdef _MACOSX_X86_X64
|
||||
CloseMacUSPCIODriver();
|
||||
|
|
@ -262,7 +269,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
WaitWhileServerOnline(ResourceManager::get()->GetServer());
|
||||
WaitWhileServerOnline(server);
|
||||
#ifdef _MACOSX_X86_X64
|
||||
CloseMacUSPCIODriver();
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue