Thrill
0.1
|
Request with completion shared_state.
Definition at line 27 of file request_with_state.hpp.
#include <request_with_state.hpp>
Public Member Functions | |
virtual | ~request_with_state () |
bool | cancel () override |
Cancel a request. More... | |
bool | poll () final |
void | wait (bool measure_time=true) final |
Suspends calling thread until completion of the request. More... | |
Public Member Functions inherited from request_with_waiters | |
request_with_waiters (const completion_handler &on_complete, file *file, void *buffer, offset_type offset, size_type bytes, read_or_write op) | |
Public Member Functions inherited from request | |
request (const completion_handler &on_complete, file *file, void *buffer, offset_type offset, size_type bytes, read_or_write op) | |
request (const request &)=delete | |
non-copyable: delete copy-constructor More... | |
request (request &&)=default | |
move-constructor: default More... | |
virtual | ~request () |
request & | operator= (const request &)=delete |
non-copyable: delete assignment operator More... | |
request & | operator= (request &&)=default |
move-assignment operator: default More... | |
file * | get_file () const |
void * | buffer () const |
offset_type | offset () const |
size_type | bytes () const |
read_or_write | op () const |
void | check_alignment () const |
std::ostream & | print (std::ostream &out) const final |
Dumps properties of a request. More... | |
void | error_occured (const char *msg) |
void | error_occured (const std::string &msg) |
void | check_errors () |
Rises an exception if there were error with the I/O. More... | |
const char * | io_type () const override |
Identifies the type of I/O implementation. More... | |
void | release_file_reference () |
Public Member Functions inherited from request_interface | |
request_interface ()=default | |
request_interface (const request_interface &)=delete | |
non-copyable: delete copy-constructor More... | |
virtual | ~request_interface () |
request_interface & | operator= (const request_interface &)=delete |
non-copyable: delete assignment operator More... | |
Public Member Functions inherited from ReferenceCounter | |
ReferenceCounter () noexcept | |
new objects have zero reference count More... | |
ReferenceCounter (const ReferenceCounter &) noexcept | |
coping still creates a new object with zero reference count More... | |
~ReferenceCounter () | |
bool | dec_reference () const noexcept |
Call whenever resetting (i.e. More... | |
void | inc_reference () const noexcept |
Call whenever setting a pointer to the object. More... | |
ReferenceCounter & | operator= (const ReferenceCounter &) noexcept |
assignment operator, leaves pointers unchanged More... | |
size_t | reference_count () const noexcept |
Return the number of references to this object (for debugging) More... | |
bool | unique () const noexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr. More... | |
Protected Types | |
enum | request_state { OP = 0, DONE = 1, READY2DIE = 2 } |
Protected Member Functions | |
request_with_state (const completion_handler &on_complete, file *file, void *buffer, offset_type offset, size_type bytes, read_or_write op) | |
void | completed (bool canceled) override |
Protected Member Functions inherited from request_with_waiters | |
bool | add_waiter (onoff_switch *sw) final |
void | delete_waiter (onoff_switch *sw) final |
void | notify_waiters () final |
size_t | num_waiters () |
returns number of waiters More... | |
Protected Member Functions inherited from request | |
void | check_nref (bool after=false) |
Protected Attributes | |
shared_state< request_state > | state_ |
Protected Attributes inherited from request | |
std::unique_ptr< io_error > | error_ |
completion_handler | on_complete_ |
file * | file_ |
file implementation to perform I/O with More... | |
void * | buffer_ |
data buffer to transfer More... | |
offset_type | offset_ |
offset within file More... | |
size_type | bytes_ |
number of bytes at buffer_ to transfer More... | |
read_or_write | op_ |
READ or WRITE. More... | |
Static Private Attributes | |
static constexpr bool | debug = false |
Additional Inherited Members | |
Public Types inherited from request_interface | |
using | offset_type = uint64_t |
type for offsets within a file More... | |
enum | read_or_write { READ, WRITE } |
using | size_type = size_t |
type for block transfer sizes More... | |
|
protected |
states of request. OP - operating, DONE - request served, READY2DIE - can be destroyed
Enumerator | |
---|---|
OP | |
DONE | |
READY2DIE |
Definition at line 34 of file request_with_state.hpp.
|
inlineprotected |
Definition at line 39 of file request_with_state.hpp.
References request_with_state::cancel(), request_with_state::completed(), request_with_state::poll(), request_with_state::wait(), and request_with_state::~request_with_state().
|
virtual |
Definition at line 27 of file request_with_state.cpp.
References request_with_state::DONE, request_with_state::READY2DIE, ReferenceCounter::reference_count(), request_with_state::state_, and TLX_LOG.
Referenced by request_with_state::request_with_state().
|
overridevirtual |
Cancel a request.
The request is canceled unless already being processed. However, cancelation cannot be guaranteed. Canceled requests must still be waited for in order to ensure correct operation. If the request was canceled successfully, the completion handler will not be called.
true
iff the request was canceled successfully Implements request_interface.
Definition at line 46 of file request_with_state.cpp.
References request::buffer_, file::delete_request_ref(), request_with_state::DONE, request::file_, singleton< disk_queues >::get_instance(), file::get_queue_id(), request_with_waiters::notify_waiters(), request::offset_, request::on_complete_, request_with_state::READY2DIE, shared_state< ValueType >::set_to(), request_with_state::state_, and TLX_LOG.
Referenced by request_with_state::request_with_state().
|
overrideprotectedvirtual |
Implements request_interface.
Definition at line 78 of file request_with_state.cpp.
References request_with_state::DONE, request_with_waiters::notify_waiters(), request::on_complete_, request_with_state::READY2DIE, request::release_file_reference(), shared_state< ValueType >::set_to(), request_with_state::state_, and TLX_LOG.
Referenced by request_with_state::request_with_state(), and serving_request::serve().
|
finalvirtual |
Polls the status of the request.
true
if request is completed, otherwise false
Implements request_interface.
Definition at line 69 of file request_with_state.cpp.
References request::check_errors(), request_with_state::DONE, request_with_state::READY2DIE, and request_with_state::state_.
Referenced by request_with_state::request_with_state().
|
finalvirtual |
Suspends calling thread until completion of the request.
Implements request_interface.
Definition at line 34 of file request_with_state.cpp.
References request::check_errors(), request::op_, request_interface::READ, request_with_state::READY2DIE, request_with_state::state_, TLX_LOG, shared_state< ValueType >::wait_for(), stats::WAIT_OP_READ, and stats::WAIT_OP_WRITE.
Referenced by request_with_state::request_with_state().
|
staticprivate |
Definition at line 29 of file request_with_state.hpp.
|
protected |
Definition at line 36 of file request_with_state.hpp.
Referenced by request_with_state::cancel(), request_with_state::completed(), request_with_state::poll(), request_with_state::wait(), and request_with_state::~request_with_state().