srsLTE: removed timout in tti semaphore

This commit is contained in:
Xavier Arteaga 2019-12-18 17:53:22 +01:00 committed by Xavier Arteaga
parent 6bef91a788
commit b1c4cd7189
1 changed files with 9 additions and 13 deletions

View File

@ -33,7 +33,6 @@ template <class T>
class tti_semaphore
{
private:
const uint32_t max_timeout_ms = 60000; // 1 minute
std::mutex mutex;
std::condition_variable cvar;
std::deque<T> fifo;
@ -41,17 +40,9 @@ private:
public:
void wait(T id)
{
bool expired = false;
std::unique_lock<std::mutex> lock(mutex);
std::chrono::system_clock::time_point expire_time = std::chrono::system_clock::now();
expire_time += std::chrono::milliseconds(max_timeout_ms);
while (!fifo.empty() && fifo.front() != id && !expired) {
expired = (cvar.wait_until(lock, expire_time) == std::cv_status::timeout);
}
if (expired) {
perror("TTI semaphore wait timeout");
std::unique_lock<std::mutex> lock(mutex);
while (!fifo.empty() && fifo.front() != id) {
cvar.wait(lock);
}
}
@ -68,7 +59,12 @@ public:
cvar.notify_all();
}
void wait_all() { wait(-1); }
void wait_all()
{
while (!fifo.empty()) {
wait(fifo.front());
}
}
};
} // namespace srslte