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
|
class tti_semaphore
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const uint32_t max_timeout_ms = 60000; // 1 minute
|
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::condition_variable cvar;
|
std::condition_variable cvar;
|
||||||
std::deque<T> fifo;
|
std::deque<T> fifo;
|
||||||
|
@ -41,17 +40,9 @@ private:
|
||||||
public:
|
public:
|
||||||
void wait(T id)
|
void wait(T id)
|
||||||
{
|
{
|
||||||
bool expired = false;
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
std::unique_lock<std::mutex> lock(mutex);
|
while (!fifo.empty() && fifo.front() != id) {
|
||||||
std::chrono::system_clock::time_point expire_time = std::chrono::system_clock::now();
|
cvar.wait(lock);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +59,12 @@ public:
|
||||||
cvar.notify_all();
|
cvar.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_all() { wait(-1); }
|
void wait_all()
|
||||||
|
{
|
||||||
|
while (!fifo.empty()) {
|
||||||
|
wait(fifo.front());
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace srslte
|
} // namespace srslte
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue