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

Timer processor manages all timers in the VSM. More...

#include <timer_processor.h>

Inheritance diagram for ugcs::vsm::Timer_processor:
ugcs::vsm::Request_context< is_processor > ugcs::vsm::Request_container

Classes

class  Timer
 Represents timer instance. More...
 

Public Types

typedef std::shared_ptr< Timer_processorPtr
 Pointer type.
 
typedef std::weak_ptr< Timer_processorWeak_ptr
 Pointer type.
 
typedef Callback_proxy< bool > Handler
 Timer handler. More...
 
- Public Types inherited from ugcs::vsm::Request_context< is_processor >
typedef std::shared_ptr< Request_contextPtr
 Pointer type.
 
typedef std::weak_ptr< Request_contextWeak_ptr
 Pointer type.
 
- Public Types inherited from ugcs::vsm::Request_container
enum  Type {
  Type::NONE = 0x0, Type::PROCESSOR = 0x1, Type::COMPLETION_CONTEXT = 0x2, Type::ANY = PROCESSOR | COMPLETION_CONTEXT,
  Type::TEMPORAL = 0x4, Type::TEMP_COMPLETION_CONTEXT = COMPLETION_CONTEXT | TEMPORAL
}
 Container type. More...
 
typedef std::shared_ptr< Request_containerPtr
 Pointer type.
 
typedef std::weak_ptr< Request_containerWeak_ptr
 Pointer type.
 

Public Member Functions

Timer::Ptr Create_timer (std::chrono::milliseconds interval, const Handler &handler, Request_container::Ptr container)
 Create and schedule the timer instance. More...
 
void Cancel_timer (Timer::Ptr timer)
 Cancel the specified timer in case it is running. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
virtual Type Get_type () const override
 Get this container type. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_container
 Request_container (const std::string &name, Request_waiter::Ptr waiter=Request_waiter::Create())
 Create container with default associated waiter. More...
 
bool Check_type (Type mask)
 Check if the container type conforms the specified characteristic mask. More...
 
void Submit_request (Request::Ptr request)
 Submit request to this container for further processing or notification handlers invocation. More...
 
void Submit_request_locked (Request::Ptr request, Request_waiter::Locker locker)
 The same as Submit_request, but with previously acquired lock of the associated waiter. More...
 
int Process_requests (int requests_limit=0)
 Process all currently queued requests. More...
 
int Process_requests (std::unique_lock< std::mutex > &lock, int requests_limit=0)
 Process all currently queued requests. More...
 
void Set_waiter (Request_waiter::Ptr waiter)
 Set request waiter associated with this container. More...
 
Request_waiter::Ptr Get_waiter () const
 Get request waiter associated with this container. More...
 
const std::string & Get_name ()
 Get the name of the container. More...
 
void Enable ()
 Enable the container. More...
 
void Disable ()
 Disable the container. More...
 
bool Is_enabled () const
 Check if the container is currently enabled. More...
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
template<typename... Args>
static Ptr Get_instance (Args &&...args)
 Get global or create new processor instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_container
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ugcs::vsm::Request_container
void Processing_loop ()
 Request processing loop implementation. More...
 
void Set_disabled ()
 Disable the container and notify its waiter. More...
 
- Protected Attributes inherited from ugcs::vsm::Request_container
Request_waiter::Ptr waiter
 Waiter associated with this container. More...
 
std::list< Request::Ptrrequest_queue
 Queue of pending requests, i.e. More...
 

Detailed Description

Timer processor manages all timers in the VSM.

Member Typedef Documentation

Timer handler.

It should return boolean value with the following meanings: false - stop the timer, i.e. do not perform further invocations; true - re-schedule next invocation after the initial interval.

Member Function Documentation

void ugcs::vsm::Timer_processor::Cancel_timer ( Timer::Ptr  timer)

Cancel the specified timer in case it is running.

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

Create an instance.

Timer::Ptr ugcs::vsm::Timer_processor::Create_timer ( std::chrono::milliseconds  interval,
const Handler handler,
Request_container::Ptr  container 
)

Create and schedule the timer instance.

First time it is fired after the specified interval (since the creation moment). Is it periodic or one-shot is defined by the provided handler - while it is returning "true" the timer is re-scheduled with the same interval.

Parameters
intervalTimer interval.
handlerHandler to invoke, should be non-empty. See Handler.
containerContainer where the handler will be executed.
Returns
Timer object which can be used, for example, to cancel running timer.
Exceptions
Invalid_param_exceptionif Handler or container is not set.
template<typename... Args>
static Ptr ugcs::vsm::Timer_processor::Get_instance ( Args &&...  args)
inlinestatic

Get global or create new processor instance.


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