LLFIO v2.00
Loading...
Searching...
No Matches
llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state Struct Reference

An unsynchronised i/o operation state. More...

#include "byte_io_multiplexer.hpp"

Inheritance diagram for llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state:
llfio_v2_xxx::byte_io_multiplexer::io_operation_state llfio_v2_xxx::byte_io_multiplexer::_synchronised_io_operation_state

Classes

union  payload_t
 Variant storage. More...
 

Public Member Functions

constexpr _unsynchronised_io_operation_state ()
 Construct an unknown state.
 
 _unsynchronised_io_operation_state (byte_io_handle *_h, io_operation_state_visitor *_v, registered_buffer_type &&b, deadline d, io_request< buffers_type > reqs)
 Construct a read operation state.
 
 _unsynchronised_io_operation_state (byte_io_handle *_h, io_operation_state_visitor *_v, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs)
 Construct a write operation state.
 
 _unsynchronised_io_operation_state (byte_io_handle *_h, io_operation_state_visitor *_v, registered_buffer_type &&b, deadline d, io_request< const_buffers_type > reqs, barrier_kind kind)
 Construct a barrier operation state.
 
 _unsynchronised_io_operation_state (io_result< buffers_type > &&res)
 Construct a finished read operation state.
 
 _unsynchronised_io_operation_state (io_result< const_buffers_type > &&res)
 Construct a finished write or barrier operation state.
 
 _unsynchronised_io_operation_state (const _unsynchronised_io_operation_state &)=delete
 
_unsynchronised_io_operation_stateoperator= (const _unsynchronised_io_operation_state &)=delete
 
_unsynchronised_io_operation_stateoperator= (_unsynchronised_io_operation_state &&)=delete
 
void clear_storage ()
 Used to clear the storage in this operation state.
 
virtual void * invoke (function_ptr< void *(io_operation_state_type)> c) const noexcept override
 Invoke the callable with the per-i/o state lock held, if any.
 
virtual io_operation_state_type current_state () const noexcept override
 Used to retrieve the current state of the i/o operation.
 
virtual io_result< buffers_typeget_completed_read () &&noexcept override
 After an i/o operation has finished, can be used to retrieve the result if the visitor did not.
 
virtual io_result< const_buffers_typeget_completed_write_or_barrier () &&noexcept override
 After an i/o operation has finished, can be used to retrieve the result if the visitor did not.
 
virtual io_operation_staterelocate_to (byte *to_) noexcept override
 Relocate the state to new storage, clearing the original state. Terminates the process if the state is in use.
 
void _read_initiated (lock_guard &g)
 
void _read_completed (lock_guard &g, io_result< buffers_type > &&res)
 
void _read_finished (lock_guard &g)
 
void _write_initiated (lock_guard &g)
 
void _write_completed (lock_guard &g, io_result< const_buffers_type > &&res)
 
void _barrier_initiated (lock_guard &g)
 
void _barrier_completed (lock_guard &g, io_result< const_buffers_type > &&res)
 
void _write_or_barrier_finished (lock_guard &g)
 
virtual void read_initiated ()
 
virtual void read_completed (io_result< buffers_type > &&res)
 
virtual void read_finished ()
 
virtual void write_initiated ()
 
virtual void write_completed (io_result< const_buffers_type > &&res)
 
virtual void barrier_initiated ()
 
virtual void barrier_completed (io_result< const_buffers_type > &&res)
 
virtual void write_or_barrier_finished ()
 

Public Attributes

io_operation_state_type state {io_operation_state_type::unknown}
 The current lifecycle state of this i/o operation.
 
union llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::payload_t payload
 
byte_io_handleh {nullptr}
 The i/o handle the i/o operation is upon.
 
io_operation_state_visitorvisitor {nullptr}
 The state visitor supplied when the operation was initialised.
 

Protected Member Functions

 _unsynchronised_io_operation_state (_unsynchronised_io_operation_state &&o) noexcept
 
virtual void _lock () noexcept
 
virtual void _unlock () noexcept
 

Detailed Description

An unsynchronised i/o operation state.

This implementation does NOT use atomics during access.

Constructor & Destructor Documentation

◆ _unsynchronised_io_operation_state() [1/7]

constexpr llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( )
inlineconstexpr

Construct an unknown state.

804{}

◆ _unsynchronised_io_operation_state() [2/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( byte_io_handle _h,
io_operation_state_visitor _v,
registered_buffer_type &&  b,
deadline  d,
io_request< buffers_type reqs 
)
inline

Construct a read operation state.

808 : io_operation_state(_h, _v)
809 , state(io_operation_state_type::read_initialised)
810 , payload(std::move(b), d, std::move(reqs))
811 {
812 }
io_operation_state_type state
The current lifecycle state of this i/o operation.
Definition byte_io_multiplexer.hpp:705

◆ _unsynchronised_io_operation_state() [3/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( byte_io_handle _h,
io_operation_state_visitor _v,
registered_buffer_type &&  b,
deadline  d,
io_request< const_buffers_type reqs 
)
inline

Construct a write operation state.

816 : io_operation_state(_h, _v)
817 , state(io_operation_state_type::write_initialised)
818 , payload(std::move(b), d, std::move(reqs))
819 {
820 }

◆ _unsynchronised_io_operation_state() [4/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( byte_io_handle _h,
io_operation_state_visitor _v,
registered_buffer_type &&  b,
deadline  d,
io_request< const_buffers_type reqs,
barrier_kind  kind 
)
inline

Construct a barrier operation state.

824 : io_operation_state(_h, _v)
825 , state(io_operation_state_type::barrier_initialised)
826 , payload(std::move(b), d, std::move(reqs), kind)
827 {
828 }

◆ _unsynchronised_io_operation_state() [5/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( io_result< buffers_type > &&  res)
inlineexplicit

Construct a finished read operation state.

831 : state(io_operation_state_type::read_finished)
832 , payload(std::move(res))
833 {
834 }

◆ _unsynchronised_io_operation_state() [6/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( io_result< const_buffers_type > &&  res)
inlineexplicit

Construct a finished write or barrier operation state.

837 : state(io_operation_state_type::write_or_barrier_finished)
838 , payload(std::move(res))
839 {
840 }

◆ _unsynchronised_io_operation_state() [7/7]

llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_unsynchronised_io_operation_state ( _unsynchronised_io_operation_state &&  o)
inlineprotectednoexcept
848 : io_operation_state(std::move(o))
849 , state(o.state)
850 {
851 }

◆ ~_unsynchronised_io_operation_state()

virtual llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::~_unsynchronised_io_operation_state ( )
inlinevirtual
854{ clear_storage(); }
void clear_storage()
Used to clear the storage in this operation state.
Definition byte_io_multiplexer.hpp:857

Member Function Documentation

◆ _barrier_completed()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_barrier_completed ( lock_guard g,
io_result< const_buffers_type > &&  res 
)
inline
1019 {
1020 if(state == io_operation_state_type::barrier_initialised || state == io_operation_state_type::barrier_initiated)
1021 {
1022 clear_storage();
1023 new(&payload.completed_write_or_barrier) io_result<const_buffers_type>(std::move(res));
1024 auto old = state;
1025 state = io_operation_state_type::write_or_barrier_completed;
1026 if(this->visitor != nullptr)
1027 {
1028 this->visitor->barrier_completed(g, old, std::move(payload.completed_write_or_barrier));
1029 }
1030 }
1031 }
virtual bool barrier_completed(lock_guard &, io_operation_state_type, io_result< const_buffers_type > &&)
Called when an i/o has completed, and its result is available. Return true if you consume the result.
Definition byte_io_multiplexer.hpp:692
io_operation_state_visitor * visitor
The state visitor supplied when the operation was initialised.
Definition byte_io_multiplexer.hpp:597
io_result< const_buffers_type > completed_write_or_barrier
Storage for a completed write or barrier i/o, the buffers drained.
Definition byte_io_multiplexer.hpp:774

◆ _barrier_initiated()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_barrier_initiated ( lock_guard g)
inline
1008 {
1009 if(state == io_operation_state_type::barrier_initialised)
1010 {
1011 state = io_operation_state_type::barrier_initiated;
1012 if(this->visitor != nullptr)
1013 {
1014 this->visitor->barrier_initiated(g, io_operation_state_type::barrier_initialised);
1015 }
1016 }
1017 }
virtual void barrier_initiated(lock_guard &, io_operation_state_type)
Called when an i/o has been initiated, and is now being processed asynchronously.
Definition byte_io_multiplexer.hpp:690

◆ _lock()

virtual void llfio_v2_xxx::byte_io_multiplexer::io_operation_state::_lock ( )
inlineprotectedvirtualnoexceptinherited
657{}

◆ _read_completed()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_read_completed ( lock_guard g,
io_result< buffers_type > &&  res 
)
inline
958 {
959 if(state == io_operation_state_type::read_initialised || state == io_operation_state_type::read_initiated)
960 {
962 new(&payload.completed_read) io_result<buffers_type>(std::move(res));
963 auto old = state;
964 state = io_operation_state_type::read_completed;
965 if(this->visitor != nullptr)
966 {
967 this->visitor->read_completed(g, old, std::move(payload.completed_read));
968 }
969 }
970 }
virtual bool read_completed(lock_guard &, io_operation_state_type, io_result< buffers_type > &&)
Called when an i/o has completed, and its result is available. Return true if you consume the result.
Definition byte_io_multiplexer.hpp:682
io_result< buffers_type > completed_read
Storage for a completed read i/o, the buffers filled.
Definition byte_io_multiplexer.hpp:772

◆ _read_finished()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_read_finished ( lock_guard g)
inline
972 {
973 if(state == io_operation_state_type::read_completed)
974 {
975 state = io_operation_state_type::read_finished;
976 if(this->visitor != nullptr)
977 {
978 this->visitor->read_finished(g, io_operation_state_type::read_completed);
979 }
980 }
981 }
virtual void read_finished(lock_guard &, io_operation_state_type)
Called when an i/o has finished, and its state can now be destroyed.
Definition byte_io_multiplexer.hpp:684

◆ _read_initiated()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_read_initiated ( lock_guard g)
inline
947 {
948 if(state == io_operation_state_type::read_initialised)
949 {
950 state = io_operation_state_type::read_initiated;
951 if(this->visitor != nullptr)
952 {
953 this->visitor->read_initiated(g, io_operation_state_type::read_initialised);
954 }
955 }
956 }
virtual void read_initiated(lock_guard &, io_operation_state_type)
Called when an i/o has been initiated, and is now being processed asynchronously.
Definition byte_io_multiplexer.hpp:680

◆ _unlock()

virtual void llfio_v2_xxx::byte_io_multiplexer::io_operation_state::_unlock ( )
inlineprotectedvirtualnoexceptinherited
658{}

◆ _write_completed()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_write_completed ( lock_guard g,
io_result< const_buffers_type > &&  res 
)
inline
994 {
995 if(state == io_operation_state_type::write_initialised || state == io_operation_state_type::write_initiated)
996 {
998 new(&payload.completed_write_or_barrier) io_result<const_buffers_type>(std::move(res));
999 auto old = state;
1000 state = io_operation_state_type::write_or_barrier_completed;
1001 if(this->visitor != nullptr)
1002 {
1003 this->visitor->write_completed(g, old, std::move(payload.completed_write_or_barrier));
1004 }
1005 }
1006 }
virtual bool write_completed(lock_guard &, io_operation_state_type, io_result< const_buffers_type > &&)
Called when an i/o has completed, and its result is available. Return true if you consume the result.
Definition byte_io_multiplexer.hpp:688

◆ _write_initiated()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_write_initiated ( lock_guard g)
inline
983 {
984 if(state == io_operation_state_type::write_initialised)
985 {
986 state = io_operation_state_type::write_initiated;
987 if(this->visitor != nullptr)
988 {
989 this->visitor->write_initiated(g, io_operation_state_type::write_initialised);
990 }
991 }
992 }
virtual void write_initiated(lock_guard &, io_operation_state_type)
Called when an i/o has been initiated, and is now being processed asynchronously.
Definition byte_io_multiplexer.hpp:686

◆ _write_or_barrier_finished()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::_write_or_barrier_finished ( lock_guard g)
inline
1033 {
1034 if(state == io_operation_state_type::write_or_barrier_completed)
1035 {
1036 state = io_operation_state_type::write_or_barrier_finished;
1037 if(this->visitor != nullptr)
1038 {
1039 this->visitor->write_or_barrier_finished(g, io_operation_state_type::write_or_barrier_completed);
1040 }
1041 }
1042 }
virtual void write_or_barrier_finished(lock_guard &, io_operation_state_type)
Called when an i/o has finished, and its state can now be destroyed.
Definition byte_io_multiplexer.hpp:694

◆ barrier_completed()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::barrier_completed ( io_result< const_buffers_type > &&  res)
inlinevirtual
1075 {
1076 lock_guard g(this, false);
1077 _barrier_completed(g, std::move(res));
1078 }

◆ barrier_initiated()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::barrier_initiated ( )
inlinevirtual
1070 {
1071 lock_guard g(this, false);
1072 _barrier_initiated(g);
1073 }

◆ clear_storage()

void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::clear_storage ( )
inline

Used to clear the storage in this operation state.

858 {
859 switch(state)
860 {
861 case io_operation_state_type::unknown:
862 break;
863 case io_operation_state_type::read_initialised:
864 case io_operation_state_type::read_initiated:
865 payload.noncompleted.base.~registered_buffer_type();
866 payload.noncompleted.d.~deadline();
867 payload.noncompleted.params.read.~read_params_t();
868 break;
869 case io_operation_state_type::read_completed:
870 case io_operation_state_type::read_finished:
871 payload.completed_read.~io_result<buffers_type>();
872 break;
873 case io_operation_state_type::write_initialised:
874 case io_operation_state_type::write_initiated:
875 payload.noncompleted.base.~registered_buffer_type();
876 payload.noncompleted.d.~deadline();
877 payload.noncompleted.params.write.~write_params_t();
878 break;
879 case io_operation_state_type::barrier_initialised:
880 case io_operation_state_type::barrier_initiated:
881 payload.noncompleted.base.~registered_buffer_type();
882 payload.noncompleted.d.~deadline();
883 payload.noncompleted.params.barrier.~barrier_params_t();
884 break;
885 case io_operation_state_type::write_or_barrier_completed:
886 case io_operation_state_type::write_or_barrier_finished:
888 break;
889 }
890 state = io_operation_state_type::unknown;
891 }
span< const_buffer_type > const_buffers_type
The gather buffers type used by this handle. Guaranteed to be TrivialType apart from construction,...
Definition byte_io_multiplexer.hpp:388
span< buffer_type > buffers_type
The scatter buffers type used by this handle. Guaranteed to be TrivialType apart from construction,...
Definition byte_io_multiplexer.hpp:386
deadline d
The deadline to complete the i/o by, if any.
Definition byte_io_multiplexer.hpp:717
registered_buffer_type base
The registered buffer to use for the i/o, if any.
Definition byte_io_multiplexer.hpp:715

◆ current_state()

virtual io_operation_state_type llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::current_state ( ) const
inlineoverridevirtualnoexcept

Used to retrieve the current state of the i/o operation.

Implements llfio_v2_xxx::byte_io_multiplexer::io_operation_state.

Reimplemented in llfio_v2_xxx::byte_io_multiplexer::_synchronised_io_operation_state.

894{ return state; }

◆ get_completed_read()

virtual io_result< buffers_type > llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::get_completed_read ( ) &&
inlineoverridevirtualnoexcept

After an i/o operation has finished, can be used to retrieve the result if the visitor did not.

Implements llfio_v2_xxx::byte_io_multiplexer::io_operation_state.

Reimplemented in llfio_v2_xxx::byte_io_multiplexer::_synchronised_io_operation_state.

896 {
897 assert(state == io_operation_state_type::read_completed || state == io_operation_state_type::read_finished);
898 io_result<buffers_type> ret(std::move(payload.completed_read));
900 return ret;
901 }

◆ get_completed_write_or_barrier()

virtual io_result< const_buffers_type > llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::get_completed_write_or_barrier ( ) &&
inlineoverridevirtualnoexcept

After an i/o operation has finished, can be used to retrieve the result if the visitor did not.

Implements llfio_v2_xxx::byte_io_multiplexer::io_operation_state.

Reimplemented in llfio_v2_xxx::byte_io_multiplexer::_synchronised_io_operation_state.

903 {
904 assert(state == io_operation_state_type::write_or_barrier_completed || state == io_operation_state_type::write_or_barrier_finished);
905 io_result<const_buffers_type> ret(std::move(payload.completed_write_or_barrier));
907 return ret;
908 }

◆ invoke()

virtual void * llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::invoke ( function_ptr< void *(io_operation_state_type)>  c) const
inlineoverridevirtualnoexcept

Invoke the callable with the per-i/o state lock held, if any.

Implements llfio_v2_xxx::byte_io_multiplexer::io_operation_state.

Reimplemented in llfio_v2_xxx::byte_io_multiplexer::_synchronised_io_operation_state.

893{ return c(state); }

◆ read_completed()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::read_completed ( io_result< buffers_type > &&  res)
inlinevirtual
1050 {
1051 lock_guard g(this, false);
1052 _read_completed(g, std::move(res));
1053 }

◆ read_finished()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::read_finished ( )
inlinevirtual
1055 {
1056 lock_guard g(this, false);
1057 _read_finished(g);
1058 }

◆ read_initiated()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::read_initiated ( )
inlinevirtual
1045 {
1046 lock_guard g(this, false);
1047 _read_initiated(g);
1048 }

◆ relocate_to()

virtual io_operation_state * llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::relocate_to ( byte *  to)
inlineoverridevirtualnoexcept

Relocate the state to new storage, clearing the original state. Terminates the process if the state is in use.

Implements llfio_v2_xxx::byte_io_multiplexer::io_operation_state.

910 {
911 auto *to = new(to_) _unsynchronised_io_operation_state(std::move(*this));
912 switch(state)
913 {
914 case io_operation_state_type::unknown:
915 break;
916 case io_operation_state_type::read_initialised:
917 case io_operation_state_type::read_initiated:
918 new(&to->payload) _unsynchronised_io_operation_state::payload_t(std::move(payload.noncompleted.base), payload.noncompleted.d,
919 std::move(payload.noncompleted.params.read.reqs));
920 break;
921 case io_operation_state_type::read_completed:
922 case io_operation_state_type::read_finished:
923 new(&to->payload.completed_read) io_result<buffers_type>(std::move(payload.completed_read));
924 break;
925 case io_operation_state_type::write_initialised:
926 case io_operation_state_type::write_initiated:
927 new(&to->payload) _unsynchronised_io_operation_state::payload_t(std::move(payload.noncompleted.base), payload.noncompleted.d,
928 std::move(payload.noncompleted.params.write.reqs));
929 break;
930 case io_operation_state_type::barrier_initialised:
931 case io_operation_state_type::barrier_initiated:
932 new(&to->payload)
933 _unsynchronised_io_operation_state::payload_t(std::move(payload.noncompleted.base), payload.noncompleted.d,
934 std::move(payload.noncompleted.params.barrier.reqs), payload.noncompleted.params.barrier.kind);
935 break;
936 case io_operation_state_type::write_or_barrier_completed:
937 case io_operation_state_type::write_or_barrier_finished:
938 new(&to->payload.completed_write_or_barrier) io_result<const_buffers_type>(std::move(payload.completed_write_or_barrier));
939 break;
940 }
942 return to;
943 }
constexpr _unsynchronised_io_operation_state()
Construct an unknown state.
Definition byte_io_multiplexer.hpp:804

◆ write_completed()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::write_completed ( io_result< const_buffers_type > &&  res)
inlinevirtual
1065 {
1066 lock_guard g(this, false);
1067 _write_completed(g, std::move(res));
1068 }

◆ write_initiated()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::write_initiated ( )
inlinevirtual
1060 {
1061 lock_guard g(this, false);
1062 _write_initiated(g);
1063 }

◆ write_or_barrier_finished()

virtual void llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::write_or_barrier_finished ( )
inlinevirtual
1080 {
1081 lock_guard g(this, false);
1082 _write_or_barrier_finished(g);
1083 }

Member Data Documentation

◆ h

byte_io_handle* llfio_v2_xxx::byte_io_multiplexer::io_operation_state::h {nullptr}
inherited

The i/o handle the i/o operation is upon.

595{nullptr};

◆ state

io_operation_state_type llfio_v2_xxx::byte_io_multiplexer::_unsynchronised_io_operation_state::state {io_operation_state_type::unknown}

The current lifecycle state of this i/o operation.

705{io_operation_state_type::unknown};

◆ visitor

io_operation_state_visitor* llfio_v2_xxx::byte_io_multiplexer::io_operation_state::visitor {nullptr}
inherited

The state visitor supplied when the operation was initialised.

597{nullptr};

The documentation for this struct was generated from the following file: