class ugcs::vsm::Io_request¶
Overview¶
Base request for I/O operations. More…
#include <io_request.h> class Io_request: public ugcs::vsm::Request_container::Request { public: // typedefs typedef std::shared_ptr<Io_request> Ptr; typedef std::weak_ptr<Io_request> Weak_ptr; // construction Io_request(Io_stream::Ptr stream, Io_stream::Offset offset, Io_result& result_arg); // methods template <typename... Args> static Ptr Create(Args&&... args); Io_stream::Ptr Get_stream() const; Io_stream::Offset& Offset(); void Set_result_arg(Io_result result, const Request::Locker& lock = Request::Locker()); Io_result Get_last_result(); }; // direct descendants class Read_request; class Write_request;
Inherited Members¶
public: // typedefs typedef std::shared_ptr<Request> Ptr; typedef std::weak_ptr<Request> Weak_ptr; typedef Callback_base<void>::Ptr<> Handler; typedef std::unique_lock<std::mutex> Locker; // enums enum Status; // methods template <typename... Args> static Ptr Create(Args&&... args); void Set_processing_handler(const Handler& handler); void Set_processing_handler(Handler&& handler); void Set_completion_handler(const Request_container::Ptr& context, const Handler& handler); void Set_completion_handler(const Request_container::Ptr& context, Handler&& handler); void Set_cancellation_handler(const Handler& handler); void Set_cancellation_handler(Handler&& handler); void Set_done_handler(Handler& handler); void Set_done_handler(Handler&& handler); Request_container::Ptr Get_completion_context(Locker locker = Locker()) const; void Process(bool process_request); void Complete(Status status = Status::OK, Locker locker = Locker()); void Cancel(Locker locker = Locker()); void Abort(Locker locker = Locker()); Locker Lock(bool acquire = true) const; Status Get_status() const; bool Is_completed() const; bool Is_request_processing_needed() const; bool Is_aborted() const; bool Is_processing() const; bool Is_completion_delivered() const; bool Is_completion_delivering_started() const; bool Is_done() const; bool Wait_done( bool process_ctx = true, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero() ); bool& Timed_out();
Detailed Documentation¶
Base request for I/O operations.
Typedefs¶
typedef std::shared_ptr<Io_request> Ptr
Pointer type.
typedef std::weak_ptr<Io_request> Weak_ptr
Pointer type.
Construction¶
Io_request(Io_stream::Ptr stream, Io_stream::Offset offset, Io_result& result_arg)
Construct I/O request.
Parameters:
stream |
Related I/O stream instance. |
offset |
Offset for I/O operation if applicable. If the target channel does not support the seeking this parameter is ignored. If the stream is responsible for keeping current offset it should check real offset when request is handled. |
result_arg |
Reference to result value which is passed as argument to the user provided completion handler. |
Methods¶
template <typename... Args> static Ptr Create(Args&&... args)
Create an instance.
Io_stream::Ptr Get_stream() const
Locks and gets the associated stream.
Io_stream::Offset& Offset()
Get I/O operation offset value.
void Set_result_arg(Io_result result, const Request::Locker& lock = Request::Locker())
Sets the result argument.
Parameters:
result |
Resutl value to set. |
lock |
If present, should be the already acquired lock for the request (will not be unlocked by the method), otherwise new lock is acquired and released inside the method. |
Io_result Get_last_result()
Get the most recently set result value.
XXX Return Io_result::OTHER_FAILURE if the result value was never set.