Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Commit

Permalink
quic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
s2x committed Nov 23, 2017
1 parent bac2a12 commit c918fea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/WatchDog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ namespace crazygoat::shepherd {
}

std::shared_ptr<Worker> WatchDog::getFreeWorker() {
std::future<std::shared_ptr<Worker> > fWorker = std::async(&WatchDog::workerIterator, this);

while (fWorker.wait_for(std::chrono::microseconds(5)) != std::future_status::ready) {}

return fWorker.get();
}

std::shared_ptr<Worker> WatchDog::workerIterator() {
do {
auto worker = this->workers[(++this->requestsCount) % this->count];
if (!worker->isIsWorking()) {
Expand Down
1 change: 1 addition & 0 deletions src/WatchDog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace crazygoat::shepherd {
unsigned int requestsCount;
std::vector<std::shared_ptr<Worker> > workers;
std::shared_ptr<boost::asio::deadline_timer> timer;
std::shared_ptr<Worker> workerIterator();
void watch();

public:
Expand Down

0 comments on commit c918fea

Please sign in to comment.