compileable state with some struct renaming missing
parent
59451d3a4c
commit
a83826552e
|
@ -3,4 +3,4 @@ CheckOptions:
|
||||||
- { key: readability-identifier-naming.PrivateMemberSuffix, value: "_" }
|
- { key: readability-identifier-naming.PrivateMemberSuffix, value: "_" }
|
||||||
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: "_" }
|
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: "_" }
|
||||||
- { key: readability-identifier-naming.ClassCase, value: "lower_case" }
|
- { key: readability-identifier-naming.ClassCase, value: "lower_case" }
|
||||||
- { key: readability-identifier-naming.StructCase, value: "CamelCase" }
|
- { key: readability-identifier-naming.StructCase, value: "lower_case" }
|
||||||
|
|
|
@ -73,17 +73,17 @@ env.Alias('test', env.test_program)
|
||||||
|
|
||||||
# Clang format part
|
# Clang format part
|
||||||
env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')})
|
env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')})
|
||||||
env.format_actions = []
|
env.format_actions = [];
|
||||||
def format_iter(env,files):
|
def format_iter(env,files):
|
||||||
for f in files:
|
for f in files:
|
||||||
env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f)))
|
env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f)))
|
||||||
pass
|
pass
|
||||||
env.Append(BUILDERS={'ClangTidy' : Builder(action = 'clang-tidy -extra-arg-before=-xc++ $SOURCE')})
|
env.Append(BUILDERS={'ClangTidy' : Builder(action = 'clang-tidy -extra-arg-before=-xc++ $SOURCE')})
|
||||||
env.tidy_actions = []
|
env.tidy_actions = [];
|
||||||
def tidy_iter(env,files):
|
def tidy_iter(env,files):
|
||||||
string_of_files = "";
|
string_of_files = "";
|
||||||
for f in files:
|
for f in files:
|
||||||
if(f != "/home/keldu/workspace/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ):
|
if(f != "/home/keldu/workspace/forstio/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ):
|
||||||
env.tidy_actions.append(env.AlwaysBuild(env.ClangTidy(target=f+"-clang-tidy",source=f)));
|
env.tidy_actions.append(env.AlwaysBuild(env.ClangTidy(target=f+"-clang-tidy",source=f)));
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -310,13 +310,13 @@ template <> class conveyor_feeder<void> {
|
||||||
public:
|
public:
|
||||||
virtual ~conveyor_feeder() = default;
|
virtual ~conveyor_feeder() = default;
|
||||||
|
|
||||||
virtual void feed(Void &&value = Void{}) = 0;
|
virtual void feed(void_t &&value = void_t{}) = 0;
|
||||||
virtual void fail(error &&error) = 0;
|
virtual void fail(error &&error) = 0;
|
||||||
|
|
||||||
virtual size_t space() const = 0;
|
virtual size_t space() const = 0;
|
||||||
virtual size_t queued() const = 0;
|
virtual size_t queued() const = 0;
|
||||||
|
|
||||||
virtual error swap(conveyor<Void> &&conveyor) noexcept = 0;
|
virtual error swap(conveyor<void_t> &&conveyor) noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct conveyor_and_feeder {
|
template <typename T> struct conveyor_and_feeder {
|
||||||
|
@ -477,25 +477,25 @@ template <typename Out, typename In> struct fix_void_caller {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Out> struct fix_void_caller<Out, Void> {
|
template <typename Out> struct fix_void_caller<Out, void_t> {
|
||||||
template <typename Func> static Out apply(Func &func, Void &&in) {
|
template <typename Func> static Out apply(Func &func, void_t &&in) {
|
||||||
(void)in;
|
(void)in;
|
||||||
return func();
|
return func();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename In> struct fix_void_caller<Void, In> {
|
template <typename In> struct fix_void_caller<void_t, In> {
|
||||||
template <typename Func> static Void apply(Func &func, In &&in) {
|
template <typename Func> static void_t apply(Func &func, In &&in) {
|
||||||
func(std::move(in));
|
func(std::move(in));
|
||||||
return Void{};
|
return void_t{};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct fix_void_caller<Void, Void> {
|
template <> struct fix_void_caller<void_t, void_t> {
|
||||||
template <typename Func> static Void apply(Func &func, Void &&in) {
|
template <typename Func> static void_t apply(Func &func, void_t &&in) {
|
||||||
(void)in;
|
(void)in;
|
||||||
func();
|
func();
|
||||||
return Void{};
|
return void_t{};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ public:
|
||||||
|
|
||||||
// ConveyorNode
|
// ConveyorNode
|
||||||
void get_result(error_or_value &err_or_val) noexcept override {
|
void get_result(error_or_value &err_or_val) noexcept override {
|
||||||
err_or_val.as<Void>() =
|
err_or_val.as<void_t>() =
|
||||||
critical_error("In a sink node no result can be returned");
|
critical_error("In a sink node no result can be returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,14 @@ template <typename Func> struct return_type_helper<Func, void> {
|
||||||
template <typename Func, typename T>
|
template <typename Func, typename T>
|
||||||
using return_type = typename return_type_helper<Func, T>::Type;
|
using return_type = typename return_type_helper<Func, T>::Type;
|
||||||
|
|
||||||
struct Void {};
|
struct void_t {};
|
||||||
|
|
||||||
template <typename T> struct void_fix { typedef T Type; };
|
template <typename T> struct void_fix { typedef T Type; };
|
||||||
template <> struct void_fix<void> { typedef Void Type; };
|
template <> struct void_fix<void> { typedef void_t Type; };
|
||||||
template <typename T> using fix_void = typename void_fix<T>::Type;
|
template <typename T> using fix_void = typename void_fix<T>::Type;
|
||||||
|
|
||||||
template <typename T> struct void_unfix { typedef T Type; };
|
template <typename T> struct void_unfix { typedef T Type; };
|
||||||
template <> struct void_unfix<Void> { typedef void Type; };
|
template <> struct void_unfix<void_t> { typedef void Type; };
|
||||||
template <typename T> using unfix_void = typename void_unfix<T>::Type;
|
template <typename T> using unfix_void = typename void_unfix<T>::Type;
|
||||||
|
|
||||||
template <typename... T> constexpr bool always_false = false;
|
template <typename... T> constexpr bool always_false = false;
|
||||||
|
|
|
@ -106,7 +106,7 @@ template <typename T> class error_or final : public error_or_value {
|
||||||
private:
|
private:
|
||||||
std::variant<error, fix_void<T>> value_or_error_;
|
std::variant<error, fix_void<T>> value_or_error_;
|
||||||
|
|
||||||
static_assert(!std::is_same_v<T, Void>, "Don't use internal private types");
|
static_assert(!std::is_same_v<T, void_t>, "Don't use internal private types");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
error_or() = default;
|
error_or() = default;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
*/
|
*/
|
||||||
conveyor_feeder<HeapMessageRoot<Outgoing, OutContainer>> &feeder();
|
conveyor_feeder<HeapMessageRoot<Outgoing, OutContainer>> &feeder();
|
||||||
|
|
||||||
conveyor<void> onReadDisconnected();
|
conveyor<void> on_read_disconnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @unimplemented
|
/// @unimplemented
|
||||||
|
|
|
@ -2,109 +2,109 @@ namespace saw {
|
||||||
|
|
||||||
template <typename Codec, typename Incoming, typename Outgoing,
|
template <typename Codec, typename Incoming, typename Outgoing,
|
||||||
typename InContainer, typename OutContainer, typename BufferT>
|
typename InContainer, typename OutContainer, typename BufferT>
|
||||||
StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
|
streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
|
||||||
StreamingIoPeer(
|
streaming_io_peer(
|
||||||
Own<ConveyorFeeder<HeapMessageRoot<Incoming, InContainer>>> feed,
|
own<conveyor_feeder<HeapMessageRoot<Incoming, InContainer>>> feed,
|
||||||
Own<AsyncIoStream> str)
|
own<async_io_stream> str)
|
||||||
: StreamingIoPeer{std::move(feed), std::move(str), {}, {}, {}} {}
|
: streaming_io_peer{std::move(feed), std::move(str), {}, {}, {}} {}
|
||||||
|
|
||||||
template <typename Codec, typename Incoming, typename Outgoing,
|
template <typename Codec, typename Incoming, typename Outgoing,
|
||||||
typename InContainer, typename OutContainer, typename BufferT>
|
typename InContainer, typename OutContainer, typename BufferT>
|
||||||
StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
|
streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
|
||||||
StreamingIoPeer(
|
streaming_io_peer(
|
||||||
Own<ConveyorFeeder<HeapMessageRoot<Incoming, InContainer>>> feed,
|
own<conveyor_feeder<HeapMessageRoot<Incoming, InContainer>>> feed,
|
||||||
Own<AsyncIoStream> stream, Codec codec, BufferT in, BufferT out)
|
own<async_io_stream> stream, Codec codec, BufferT in, BufferT out)
|
||||||
: incoming_feeder_{std::move(feed)},
|
: incoming_feeder_{std::move(feed)},
|
||||||
io_stream_{std::move(stream)}, codec_{std::move(codec)},
|
io_stream_{std::move(stream)}, codec_{std::move(codec)},
|
||||||
in_buffer_{std::move(in)}, out_buffer_{std::move(out)},
|
in_buffer_{std::move(in)}, out_buffer_{std::move(out)},
|
||||||
sink_read_{io_stream_->readDone()
|
sink_read_{io_stream_->read_done()
|
||||||
.then([this](size_t bytes) -> ErrorOr<void> {
|
.then([this](size_t bytes) -> error_or<void> {
|
||||||
in_buffer_.writeAdvance(bytes);
|
in_buffer_.write_advance(bytes);
|
||||||
|
|
||||||
if (in_buffer_.writeSegmentLength() == 0) {
|
if (in_buffer_.write_segment_length() == 0) {
|
||||||
return criticalError("Message too long");
|
return critical_error("Message too long");
|
||||||
}
|
}
|
||||||
|
|
||||||
io_stream_->read(&in_buffer_.write(), 1,
|
io_stream_->read(&in_buffer_.write(), 1,
|
||||||
in_buffer_.writeSegmentLength());
|
in_buffer_.write_segment_length());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto root =
|
auto root =
|
||||||
heapMessageRoot<Incoming, InContainer>();
|
heapMessageRoot<Incoming, InContainer>();
|
||||||
auto builder = root.build();
|
auto builder = root.build();
|
||||||
|
|
||||||
Error error =
|
error err =
|
||||||
codec_.template decode<Incoming, InContainer>(
|
codec_.template decode<Incoming, InContainer>(
|
||||||
builder, in_buffer_);
|
builder, in_buffer_);
|
||||||
if (error.isCritical()) {
|
if (err.is_critical()) {
|
||||||
return error;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error.failed()) {
|
if (!err.failed()) {
|
||||||
incoming_feeder_->feed(std::move(root));
|
incoming_feeder_->feed(std::move(root));
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Void{};
|
return void_t{};
|
||||||
})
|
})
|
||||||
.sink([this](Error error) {
|
.sink([this](error err) {
|
||||||
incoming_feeder_->fail(error.copyError());
|
incoming_feeder_->fail(err.copy_error());
|
||||||
|
|
||||||
return error;
|
return err;
|
||||||
})},
|
})},
|
||||||
sink_write_{io_stream_->writeDone()
|
sink_write_{io_stream_->write_done()
|
||||||
.then([this](size_t bytes) -> ErrorOr<void> {
|
.then([this](size_t bytes) -> error_or<void> {
|
||||||
out_buffer_.readAdvance(bytes);
|
out_buffer_.read_advance(bytes);
|
||||||
if (out_buffer_.readCompositeLength() > 0) {
|
if (out_buffer_.readCompositeLength() > 0) {
|
||||||
io_stream_->write(
|
io_stream_->write(
|
||||||
&out_buffer_.read(),
|
&out_buffer_.read(),
|
||||||
out_buffer_.readSegmentLength());
|
out_buffer_.read_segment_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Void{};
|
return void_t{};
|
||||||
})
|
})
|
||||||
.sink()} {
|
.sink()} {
|
||||||
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.writeSegmentLength());
|
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.write_segment_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Codec, typename Incoming, typename Outgoing,
|
template <typename Codec, typename Incoming, typename Outgoing,
|
||||||
typename InContainer, typename OutContainer, typename BufferT>
|
typename InContainer, typename OutContainer, typename BufferT>
|
||||||
Error StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer,
|
error streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
|
||||||
BufferT>::send(HeapMessageRoot<Outgoing, OutContainer>
|
BufferT>::send(HeapMessageRoot<Outgoing, OutContainer>
|
||||||
msg) {
|
msg) {
|
||||||
bool restart_write = out_buffer_.readSegmentLength() == 0;
|
bool restart_write = out_buffer_.read_segment_length() == 0;
|
||||||
|
|
||||||
Error error =
|
error err =
|
||||||
codec_.template encode<Outgoing, OutContainer>(msg.read(), out_buffer_);
|
codec_.template encode<Outgoing, OutContainer>(msg.read(), out_buffer_);
|
||||||
if (error.failed()) {
|
if (err.failed()) {
|
||||||
return error;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restart_write) {
|
if (restart_write) {
|
||||||
io_stream_->write(&out_buffer_.read(), out_buffer_.readSegmentLength());
|
io_stream_->write(&out_buffer_.read(), out_buffer_.read_segment_length());
|
||||||
}
|
}
|
||||||
|
|
||||||
return noError();
|
return no_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Codec, typename Incoming, typename Outgoing,
|
template <typename Codec, typename Incoming, typename Outgoing,
|
||||||
typename InContainer, typename OutContainer, typename BufferT>
|
typename InContainer, typename OutContainer, typename BufferT>
|
||||||
Conveyor<void> StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
|
conveyor<void> streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
|
||||||
OutContainer, BufferT>::onReadDisconnected() {
|
OutContainer, BufferT>::on_read_disconnected() {
|
||||||
return io_stream_->onReadDisconnected();
|
return io_stream_->on_read_disconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Codec, typename Incoming, typename Outgoing,
|
template <typename Codec, typename Incoming, typename Outgoing,
|
||||||
typename InContainer, typename OutContainer, typename BufferT>
|
typename InContainer, typename OutContainer, typename BufferT>
|
||||||
std::pair<Own<StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
|
std::pair<own<streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
|
||||||
OutContainer, BufferT>>,
|
OutContainer, BufferT>>,
|
||||||
Conveyor<HeapMessageRoot<Incoming, InContainer>>>
|
conveyor<HeapMessageRoot<Incoming, InContainer>>>
|
||||||
newStreamingIoPeer(Own<AsyncIoStream> stream) {
|
newstreaming_io_peer(own<async_io_stream> stream) {
|
||||||
auto caf = newConveyorAndFeeder<HeapMessageRoot<Incoming, InContainer>>();
|
auto caf = newconveyorAndFeeder<HeapMessageRoot<Incoming, InContainer>>();
|
||||||
|
|
||||||
return {heap<StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
|
return {heap<streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
|
||||||
OutContainer, BufferT>>(std::move(caf.feeder),
|
OutContainer, BufferT>>(std::move(caf.feeder),
|
||||||
std::move(stream)),
|
std::move(stream)),
|
||||||
std::move(caf.conveyor)};
|
std::move(caf.conveyor)};
|
||||||
|
|
|
@ -193,7 +193,7 @@ conveyor<own<io_stream>> TlsNetwork::connect(network_address& address) {
|
||||||
hlp_ptr->setupTurn();
|
hlp_ptr->setupTurn();
|
||||||
hlp_ptr->turn();
|
hlp_ptr->turn();
|
||||||
|
|
||||||
return Void{};
|
return void_t{};
|
||||||
});
|
});
|
||||||
|
|
||||||
helper->connection_sink = prim_conv.sink();
|
helper->connection_sink = prim_conv.sink();
|
||||||
|
|
Loading…
Reference in New Issue