ソースを参照

Some cancelled prototyping

channel
Ludovic 'Archivist' Lagouardette 3年前
コミット
4d227b7b33
1個のファイルの変更46行の追加3行の削除
  1. +46
    -3
      include/gp/ipc/channel.hpp

+ 46
- 3
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<char> 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<typename predicate>
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<gp::vector<char>> 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<std::copyable T>
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<T>
: value(gp::forward<T>(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<allocator> local_allocator_impl; //< The allocator used here
gp::vector<gp::vector<char>> 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<gp::buddy<gp_config::limits::channel_max_size/16,16>>
@ -64,7 +107,7 @@ namespace gp {
*/
template<typename predicate>
gp::optional<gp::vector<char>> try_receive(
allocator allocate,
allocator& allocate,
predicate pred = [](gp::buffer<char>){return true;}
) {
for(auto it = data.begin(); it != data.end(); ++it) {

読み込み中…
キャンセル
保存