mirror of https://github.com/PentHertz/srsLTE.git
srsLTE: removed timout in tti semaphore
This commit is contained in:
parent
6bef91a788
commit
b1c4cd7189
|
@ -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");
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue