8 #ifndef _UGCS_VSM_POSIX_FILE_HANDLE_H_
9 #define _UGCS_VSM_POSIX_FILE_HANDLE_H_
12 #include <ugcs/vsm/platform_sockets.h>
29 const std::string& path,
31 mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
60 std::shared_ptr<std::vector<uint8_t>>
read_buf;
86 Read_impl(std::unique_lock<std::mutex>&& read_lock);
virtual bool Cancel_read() override
Cancel current read operation.
Native_controller & Get_native_controller() const
Get native controlled of the related stream.
Definition: file_processor.h:256
Linux-specific implementation for I/O controller.
Definition: poll_io_controller.h:21
void Write_complete_cbk()
Completion handler for platform write call.
int fd
POSIX file descriptor for read/write operations.
Definition: posix_file_handle.h:52
virtual void Write() override
Schedule write operation based on current write request.
size_t min_read_size
Minimal number of bytes to read in current read operation.
Definition: posix_file_handle.h:66
virtual bool Unlock() override
Schedule unlock operation based on current lock request.
Io_cb write_cb
Control block for current write operation.
Definition: posix_file_handle.h:58
static void Read_complete_cbk_s(Poll_io_controller::Io_cb &io_cb)
Callback used as completion handler for platform read call.
Io_result
Result of I/O operation.
Definition: io_stream.h:37
static Io_result Map_error(int error)
Map errno value to Io_result.
Mode for file opening.
Definition: file_processor.h:69
virtual ~Posix_file_handle()
Closes descriptors on destruction.
std::shared_ptr< std::vector< uint8_t > > read_buf
Read buffer.
Definition: posix_file_handle.h:60
Posix specific I/O control block.
Definition: posix_file_handle.h:40
virtual void Close() override
Close the handle.
Posix_file_handle(int fd, int write_fd=-1)
Construct an instance based on already opened descriptors.
std::mutex write_mutex
Mutex for protecting write control block.
Definition: posix_file_handle.h:62
Poll_io_controller & Get_controller() const
Get poll controller.
Definition: posix_file_handle.h:126
std::mutex read_mutex
Mutex for protecting read control block.
Definition: posix_file_handle.h:62
virtual File_processor::Stream::Lock_result Try_lock() override
Schedule lock operation based on current lock request.
Posix_file_handle & handle
Associated handle.
Definition: posix_file_handle.h:48
Interface for platform native file handle.
Definition: file_processor.h:109
void Read_complete_cbk()
Completion handler for platform read call.
static void Write_complete_cbk_s(Poll_io_controller::Io_cb &io_cb)
Callback used as completion handler for platform write call.
virtual bool Lock() override
Schedule lock operation based on current lock request.
POSIX-specific implementation of system native file handle.
Definition: posix_file_handle.h:19
Io_cb(Posix_file_handle &handle)
Construct block bound to a handle.
Definition: posix_file_handle.h:43
void Read_impl(std::unique_lock< std::mutex > &&read_lock)
Implementation of read operation.
Lock_result
Lock operation result.
Definition: file_processor.h:59
Io_cb read_cb
Control block for current read operation.
Definition: posix_file_handle.h:56
int write_fd
Optional separate descriptor for write operations.
Definition: posix_file_handle.h:54
Control block for I/O operation.
Definition: poll_io_controller.h:25
virtual void Read() override
Schedule read operation based on current read request.
virtual bool Cancel_write() override
Cancel current write operation.