Vehicle Specific Modules SDK
ugcs::vsm::Shared_mutex_file Class Reference

Cross-platform named mutex. More...

#include <shared_mutex_file.h>

Inheritance diagram for ugcs::vsm::Shared_mutex_file:

Public Types

typedef std::shared_ptr< Shared_mutex_filePtr
 Pointer type.
typedef std::weak_ptr< Shared_mutex_fileWeak_ptr
 Pointer type.
typedef File_processor::Stream::Lock_handler Acquire_handler
 Acquire Callback prototype. More...

Public Member Functions

 Shared_mutex_file (const std::string &name, File_processor::Ptr=File_processor::Get_instance())
 Creates shared memory region which can be accessed via Acquire call. More...
template<class __Callable , typename... __Args>
 __DEFINE_CALLBACK_BUILDER_BODY (Make_acquire_handler,(Io_result),(Io_result::OTHER_FAILURE))
 Builder for acquire handler. More...
Operation_waiter Acquire (Acquire_handler completion_handler, Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Acquires exclusive lock. More...
Operation_waiter Release (Acquire_handler completion_handler=Make_dummy_callback< void, Io_result >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Releases previously acquired lock.

Static Public Member Functions

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

Detailed Description

Cross-platform named mutex.

Member Typedef Documentation

Acquire Callback prototype.

void Callback(result, void* mem_pointer, ...)

resultSee Acquire_result above
mem_pointerPointer to memory region. If the mem_pointer is not nullptr then user can freely access mem_size count bytes. User is free to use the memory from any thread.
...Any other user supplied arguments

It is ok to call Release() from this function, too.

Constructor & Destructor Documentation

ugcs::vsm::Shared_mutex_file::Shared_mutex_file ( const std::string &  name,
File_processor::Ptr  = File_processor::Get_instance() 

Creates shared memory region which can be accessed via Acquire call.

nameName of shared memory region.

Member Function Documentation

template<class __Callable , typename... __Args>
ugcs::vsm::Shared_mutex_file::__DEFINE_CALLBACK_BUILDER_BODY ( Make_acquire_handler  ,
(Io_result ,

Builder for acquire handler.

Operation_waiter ugcs::vsm::Shared_mutex_file::Acquire ( Acquire_handler  completion_handler,
Request_completion_context::Ptr  comp_ctx = Request_temp_completion_context::Create() 

Acquires exclusive lock.

completion_handlerUser supplied callback. See above.
comp_ctxUser supplied completion context in which completion_handler will execute.
Operation_waiter Can be used to acquire memory synchronously or with timeout.

IMPORTANT: Operation_waiter timoeut or cancelation DOES NOT prevent completion_handler from being called.

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

Create an instance.

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