Commit c9234ddb authored by Dominik Charousset's avatar Dominik Charousset

Implement await_data() with timeout

parent e0871803
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef CAF_BLOCKING_ACTOR_HPP #ifndef CAF_BLOCKING_ACTOR_HPP
#define CAF_BLOCKING_ACTOR_HPP #define CAF_BLOCKING_ACTOR_HPP
#include <chrono>
#include <mutex> #include <mutex>
#include <condition_variable> #include <condition_variable>
...@@ -232,6 +233,8 @@ public: ...@@ -232,6 +233,8 @@ public:
void await_data(); void await_data();
bool await_data(std::chrono::high_resolution_clock::time_point timeout);
/// @endcond /// @endcond
protected: protected:
......
...@@ -100,6 +100,12 @@ void blocking_actor::await_data() { ...@@ -100,6 +100,12 @@ void blocking_actor::await_data() {
mailbox().synchronized_await(mtx_, cv_); mailbox().synchronized_await(mtx_, cv_);
} }
bool blocking_actor::await_data(std::chrono::high_resolution_clock::time_point timeout) {
if (has_next_message())
return true;
return mailbox().synchronized_await(mtx_, cv_, timeout);
}
size_t blocking_actor::attach_functor(const actor& x) { size_t blocking_actor::attach_functor(const actor& x) {
return attach_functor(actor_cast<strong_actor_ptr>(x)); return attach_functor(actor_cast<strong_actor_ptr>(x));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment