diff --git a/include/gp/ipc/channel.hpp b/include/gp/ipc/channel.hpp index f5da029..e94885d 100644 --- a/include/gp/ipc/channel.hpp +++ b/include/gp/ipc/channel.hpp @@ -8,10 +8,53 @@ #include "gp/utils/pointers.hpp" namespace gp { + /*class abstract_sender_erasor { + virtual ~abstract_sender_erasor() = 0; + virtual bool try_send(const gp::buffer message) = 0; + }; + + class abstract_sender_erasor_c : abstract_sender_erasor { + virtual abstract_sender_erasor_c* clone(gp::allocator&) = 0; + virtual ~abstract_sender_erasor_c() = 0; + }; + + template + class abstract_receiver_erasor { + [[no_unique_address]] predicate v; + virtual abstract_receiver_erasor* clone(abstract_receiver_erasor&, gp::allocator&) = 0; + virtual ~abstract_receiver_erasor() = 0; + virtual gp::optional> try_receive(allocator& allocate) = 0; + }; + + class abstract_receiver_erasor_c : abstract_sender_erasor { + virtual abstract_receiver_erasor_c* clone(gp::allocator&) = 0; + virtual ~abstract_receiver_erasor_c() = 0; + }; + + template + class impl_channel_sender : abstract_sender_erasor_c { + T& value; + + impl_channel_sender(T& cpy) + : value(cpy) + {}; + + impl_channel_sender(T&& cpy) + requires std::movable + : value(gp::forward(cpy)) + {}; + + virtual abstract_sender_erasor_c* clone(gp::allocator& allocator) { + + } + };*/ + + + /** * @brief */ - class channel { + class basic_channel { allocator& self_allocator; //< This is from whatever created the channel and MUST outlive the channel gp::unique_ptr local_allocator_impl; //< The allocator used here gp::vector> data; @@ -24,7 +67,7 @@ namespace gp { * @param memory_source Where do we allocate from for this channel * @param memory_available The amount of memory to allocate, default specified in the configuration */ - channel(allocator& memory_source, size_t memory_available = gp_config::limits::channel_default_size) + basic_channel(allocator& memory_source, size_t memory_available = gp_config::limits::channel_default_size) : self_allocator(memory_source) , local_allocator_impl( gp::unique_ptr> @@ -64,7 +107,7 @@ namespace gp { */ template gp::optional> try_receive( - allocator allocate, + allocator& allocate, predicate pred = [](gp::buffer){return true;} ) { for(auto it = data.begin(); it != data.end(); ++it) {