class ugcs::vsm::Request_container::Request_waiter¶
Overview¶
Represents request synchronization entity which is used for request queues protected access, submission notifications and waiting. More…
#include <request_container.h> class Request_waiter: public std::enable_shared_from_this< Request_waiter > { public: // typedefs typedef std::shared_ptr<Request_waiter> Ptr; typedef std::weak_ptr<Request_waiter> Weak_ptr; typedef Callback_base<bool>::Ptr<> Predicate; // classes class Locker; // methods template <typename... Args> static Ptr Create(Args&&... args); virtual void Notify(); Locker Lock(); Locker Lock_notify(); int Wait_and_process( const std::initializer_list<Request_container::Ptr>& containers, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), int requests_limit = 0, Predicate predicate = Predicate() ); int Wait_and_process( const std::list<Request_container::Ptr>& containers, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), int requests_limit = 0, Predicate predicate = Predicate() ); }; // direct descendants class Piped_request_waiter;
Detailed Documentation¶
Represents request synchronization entity which is used for request queues protected access, submission notifications and waiting.
Typedefs¶
typedef std::shared_ptr<Request_waiter> Ptr
Pointer type.
typedef std::weak_ptr<Request_waiter> Weak_ptr
Pointer type.
typedef Callback_base<bool>::Ptr<> Predicate
Predicate for wait operations.
Returns:
“true” if wait condition met, “false” otherwise.
Methods¶
template <typename... Args> static Ptr Create(Args&&... args)
Create an instance.
virtual void Notify()
Notify all listeners about request submission.
Locker Lock()
Acquire lock for request getting.
Locker Lock_notify()
Acquire lock for request submission.
Returns:
Locker object which own the acquired lock (RAII helper). Once the locker is destroyed the waiter is unlocked and notified.
int Wait_and_process( const std::initializer_list<Request_container::Ptr>& containers, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), int requests_limit = 0, Predicate predicate = Predicate() )
Wait for request submission.
It blocks until request submitted or the specified timeout elapses. If there are some requests submitted they are processed. After processing the method exits.
Parameters:
containers |
List of containers to check and wait for. |
timeout |
Timeout in milliseconds. Zero value indicates indefinite waiting. |
requests_limit |
Limit of requests to process at once. Zero means no limit. |
predicate |
Predicate to check during waiting. It overrides default predicate which checks number of processed requests. |
Returns:
Number of requests processed.
int Wait_and_process( const std::list<Request_container::Ptr>& containers, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), int requests_limit = 0, Predicate predicate = Predicate() )
Wait for request submission.
It blocks until request submitted or the specified timeout elapses. If there are some requests submitted they are processed. After processing the method exits.
Parameters:
containers |
List of containers to check and wait for. |
timeout |
Timeout in milliseconds. Zero value indicates indefinite waiting. |
requests_limit |
Limit of requests to process at once. Zero means no limit. |
predicate |
Predicate to check during waiting. It overrides default predicate which checks number of processed requests. |
Returns:
Number of requests processed.