VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
shared_mutex_file.h
Go to the documentation of this file.
1 // Copyright (c) 2018, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
9 #ifndef _UGCS_VSM_SHARED_MUTEX_FILE_H_
10 #define _UGCS_VSM_SHARED_MUTEX_FILE_H_
11 
12 #include <ugcs/vsm/callback.h>
14 
15 namespace ugcs {
16 namespace vsm {
17 
19 class Shared_mutex_file: public std::enable_shared_from_this<Shared_mutex_file>
20 {
22 public:
34  typedef File_processor::Stream::Lock_handler Acquire_handler;
35 
40  Shared_mutex_file(const std::string& name, File_processor::Ptr = File_processor::Get_instance());
41 
42  virtual ~Shared_mutex_file();
43 
46  Make_acquire_handler,
47  (Io_result),
48  (Io_result::OTHER_FAILURE));
49 
64  Acquire(Acquire_handler completion_handler,
66 
71  Release(Acquire_handler completion_handler = Make_dummy_callback<void, Io_result>(),
73 private:
74  File_processor::Stream::Ref stream;
75 };
76 
77 } /* namespace vsm */
78 } /* namespace ugcs */
79 #endif /* _UGCS_VSM_SHARED_MUTEX_FILE_H_ */
std::shared_ptr< Shared_mutex_file > Ptr
Pointer type.
Definition: shared_mutex_file.h:21
#define DEFINE_CALLBACK_BUILDER(__name, __types, __values)
Define callback builder function.
Definition: callback.h:42
Io_result
Result of I/O operation.
Definition: io_stream.h:37
Generic callback which can be used to define and create an instance of an abstract callable operation...
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.
Request execution context.
Definition: request_context.h:24
Some other system failure.
Cross-platform named mutex.
Definition: shared_mutex_file.h:19
static Ptr Create(Args &&...args)
Create an instance.
Definition: shared_mutex_file.h:21
Helper class for proxying callback invocation.
Definition: callback.h:694
Operation_waiter Acquire(Acquire_handler completion_handler, Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
Acquires exclusive lock.
callback_internal::Dummy_callback_helper< Result, Args...>::Callback_type::Ptr Make_dummy_callback()
Create dummy callback.
Definition: callback.h:446
Temporal request completion context.
Definition: request_temp_completion_context.h:18
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
Processor for working with filesystem I/O.
Definition: file_processor.h:31
Processor for handling file I/O.
Class for synchronizing with request execution.
Definition: operation_waiter.h:24