mirror of
https://github.com/Telecominfraproject/wlan-cloud-owls.git
synced 2026-01-27 02:22:44 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -52,13 +52,13 @@ namespace OpenWifi {
|
||||
|
||||
void SimulationRunner::Stop() {
|
||||
if (Running_) {
|
||||
Running_ = false;
|
||||
Reactor_.stop();
|
||||
SocketReactorThread_.join();
|
||||
Running_ = false;
|
||||
for(auto &client:Clients_) {
|
||||
OWLSclientEvents::Disconnect(client.second, this, "Simulation shutting down", false);
|
||||
client.second->Valid_ = false;
|
||||
}
|
||||
Reactor_.stop();
|
||||
SocketReactorThread_.join();
|
||||
Clients_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ namespace Bosma {
|
||||
explicit Scheduler(unsigned int max_n_tasks = 4) : done(false), threads(max_n_tasks + 1) {
|
||||
threads.push([this](int) {
|
||||
while (!done) {
|
||||
if (tasks.empty()) {
|
||||
sleeper.sleep();
|
||||
Clock::time_point sleep_until_time;
|
||||
if(find_sleep_time(sleep_until_time)) {
|
||||
sleeper.sleep_until(sleep_until_time);
|
||||
} else {
|
||||
auto time_of_first_task = (*tasks.begin()).first;
|
||||
sleeper.sleep_until(time_of_first_task);
|
||||
sleeper.sleep();
|
||||
}
|
||||
manage_tasks();
|
||||
}
|
||||
@@ -183,6 +183,15 @@ namespace Bosma {
|
||||
sleeper.interrupt();
|
||||
}
|
||||
|
||||
bool find_sleep_time(Clock::time_point &sleep_value) {
|
||||
std::lock_guard<std::mutex> l(lock);
|
||||
if(tasks.empty()) {
|
||||
return false;
|
||||
}
|
||||
sleep_value = (*tasks.begin()).first;
|
||||
return true;
|
||||
}
|
||||
|
||||
void manage_tasks() {
|
||||
std::lock_guard<std::mutex> l(lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user