VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Request_container::Request_waiter Class Reference

Represents request synchronization entity which is used for request queues protected access, submission notifications and waiting. More...

#include <request_container.h>

Inheritance diagram for ugcs::vsm::Request_container::Request_waiter:
ugcs::vsm::Piped_request_waiter

Classes

class  Locker
 Helper class for RAII-based locking and notifying Request_waiter objects. More...
 

Public Types

typedef std::shared_ptr< Request_waiterPtr
 Pointer type.
 
typedef std::weak_ptr< Request_waiterWeak_ptr
 Pointer type.
 
typedef Callback_base< bool >::Ptr<> Predicate
 Predicate for wait operations. More...
 

Public Member Functions

virtual void Notify ()
 Notify all listeners about request submission. More...
 
Locker Lock ()
 Acquire lock for request getting. More...
 
Locker Lock_notify ()
 Acquire lock for request submission. More...
 
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. More...
 
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. More...
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 

Friends

class Locker
 

Detailed Description

Represents request synchronization entity which is used for request queues protected access, submission notifications and waiting.

Member Typedef Documentation

Predicate for wait operations.

Returns
"true" if wait condition met, "false" otherwise.

Member Function Documentation

template<typename... Args>
static Ptr ugcs::vsm::Request_container::Request_waiter::Create ( Args &&...  args)
inlinestatic

Create an instance.

Examples:
async_workflow.cpp.
Locker ugcs::vsm::Request_container::Request_waiter::Lock ( )

Acquire lock for request getting.

Locker ugcs::vsm::Request_container::Request_waiter::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.
virtual void ugcs::vsm::Request_container::Request_waiter::Notify ( )
virtual

Notify all listeners about request submission.

Reimplemented in ugcs::vsm::Piped_request_waiter.

int ugcs::vsm::Request_container::Request_waiter::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
containersList of containers to check and wait for.
timeoutTimeout in milliseconds. Zero value indicates indefinite waiting.
requests_limitLimit of requests to process at once. Zero means no limit.
predicatePredicate to check during waiting. It overrides default predicate which checks number of processed requests.
Returns
Number of requests processed.
int ugcs::vsm::Request_container::Request_waiter::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
containersList of containers to check and wait for.
timeoutTimeout in milliseconds. Zero value indicates indefinite waiting.
requests_limitLimit of requests to process at once. Zero means no limit.
predicatePredicate to check during waiting. It overrides default predicate which checks number of processed requests.
Returns
Number of requests processed.

The documentation for this class was generated from the following file: