VSM C++ SDK
Vehicle Specific Modules SDK
shared_mutex_file.h
Go to the documentation of this file.
1 // Copyright (c) 2014, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
9 #ifndef SHARED_MUTEX_FILE_H_
10 #define 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:
23 
35  typedef File_processor::Stream::Lock_handler Acquire_handler;
36 
41  Shared_mutex_file(const std::string& name, File_processor::Ptr = File_processor::Get_instance());
42 
43  virtual ~Shared_mutex_file();
44 
47  Make_acquire_handler,
48  (Io_result),
49  (Io_result::OTHER_FAILURE));
50 
65  Acquire(Acquire_handler completion_handler,
67 
72  Release(Acquire_handler completion_handler = Make_dummy_callback<void, Io_result>(),
74 private:
75  File_processor::Stream::Ref stream;
76 };
77 
78 } /* namespace vsm */
79 } /* namespace ugcs */
80 #endif /* SHARED_MUTEX_FILE_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
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
STL namespace.
Io_result
Result of I/O operation.
Definition: io_stream.h:25
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:691
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:444
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:32
Processor for handling file I/O.
Class for synchronizing with request execution.
Definition: operation_waiter.h:24