terminal.h
Go to the documentation of this file.
20 * Elements of the data structure can be accessed using get method, which calls the at method of the Container.
34 template<typename T, typename mapperT, typename keymapT, std::enable_if_t<!std::is_same<std::decay_t<T>,
148 static_assert(std::is_same_v<keyT, std::decay_t<keyT>>, "In<keyT,valueT> assumes keyT is a non-decayable type");
158 using prepare_send_callback_type = meta::detail::prepare_send_callback_t<keyT, std::decay_t<valueT>>;
180 In() : InTerminalBase<keyT>(std::is_const_v<valueT> ? TerminalBase::Type::Read : TerminalBase::Type::Consume){};
192 void set_callback(const send_callback_type &send_callback, const move_callback_type &move_callback,
207 static_assert(meta::is_none_void_v<keyT, valueT>, "ttg::send<>() sending to a terminal expecting void key and value; use ttg::send<>() instead");
208 static_assert(!meta::is_void_v<keyT>, "ttg::send<>(key,value) sending to a terminal expecting void key; use ttg::sendv(value) instead");
209 static_assert(!meta::is_void_v<valueT>, "ttg::send<>(key,value) sending to a terminal expecting void value; use ttg::sendk(key) instead");
222 static_assert(!meta::is_void_v<keyT> && meta::is_void_v<valueT>, "ttg::sendk<>(key) sending to a terminal expecting void key and nonvoid value; use ttg::sendv<>(value) instead");
223 static_assert(!meta::is_void_v<keyT>, "ttg::sendk<>(key) sending to a terminal expecting void key; use ttg::send() instead");
224 static_assert(meta::is_void_v<valueT>, "ttg::sendk<>(key) sending to a terminal expecting nonvoid value; use ttg::send(key,value) instead");
232 static_assert(meta::is_void_v<keyT> && !meta::is_void_v<valueT>, "ttg::sendv<>(value) sending to a terminal expecting nonvoid key and void value; use ttg::sendk<>(key) instead");
233 static_assert(meta::is_void_v<keyT>, "ttg::sendv<>(value) sending to a terminal expecting nonvoid key; use ttg::send(key, value) instead");
234 static_assert(!meta::is_void_v<valueT>, "ttg::sendv<>(value) sending to a terminal expecting void value; use ttg::send() instead");
247 static_assert(!meta::is_none_void_v<keyT, valueT>, "ttg::send<>() sending to a terminal expecting nonvoid key and value; use ttg::send<>(key,value) instead");
248 static_assert(meta::is_void_v<keyT>, "ttg::send<>() sending to a terminal expecting nonvoid key; use ttg::sendk<>(key) instead");
249 static_assert(meta::is_void_v<valueT>, "ttg::send<>() sending to a terminal expecting nonvoid value; use ttg::sendv<>(value) instead");
257 std::enable_if_t<!meta::is_void_v<Value>, void> broadcast(const rangeT &keylist, const Value &value) {
260 broadcast_callback(ttg::span<const keyT>(&(*std::begin(keylist)), std::distance(std::begin(keylist), std::end(keylist))),
277 std::enable_if_t<!meta::is_void_v<Value>, void> broadcast(const rangeT &keylist, Value &&value) {
282 ttg::span<const keyT>(&(*std::begin(keylist)), std::distance(std::begin(keylist), std::end(keylist))), v);
302 ttg::span<const keyT>(&(*std::begin(keylist)), std::distance(std::begin(keylist), std::end(keylist))));
376 static_assert(std::is_same_v<keyT, std::decay_t<keyT>>, "Out<keyT,valueT> assumes keyT is a non-decayable type");
455 std::string("you are trying to connect terminals with incompatible types:\ntype of this Terminal = ") +
456 detail::demangled_type_name(this) + "\ntype of other Terminal" + detail::demangled_type_name(in));
461 std::string("you are trying to connect terminals with incompatible types:\ntype of this Terminal = ") +
462 detail::demangled_type_name(this) + "\ntype of other Terminal" + detail::demangled_type_name(in));
464 throw std::invalid_argument(std::string("you are trying to connect an Out terminal to another Out terminal"));
465 trace(rank(), ": connected Out<> ", this->get_name(), "(ptr=", this, ") to In<> ", in->get_name(), "(ptr=", in,
494 // if only have 1 successor forward value even if successor is read-only, so we can deal with move-only types
515 trace(rank(), ": in ", this->get_name(), "(ptr=", this, ") Out<>::send: #successors=", this->successors().size());
525 trace("Out<> ", this->get_name(), "(ptr=", this, ") send to In<> ", successor->get_name(), "(ptr=", successor,
539 // if only have 1 successor forward value even if successor is read-only, so we can deal with move-only types
574 std::enable_if_t<meta::is_none_void_v<Key> && meta::is_void_v<valueT>, void> broadcast(const rangeT &keylist) {
591 return static_cast<In<keyT, std::add_const_t<valueT>> *>(successor)->prepare_send(keylist, value);
632 inline constexpr bool decays_to_output_terminal_tuple_v = is_output_terminal_tuple_v<std::decay_t<T>>;
634 struct decays_to_output_terminal_tuple : std::bool_constant<decays_to_output_terminal_tuple_v<T>> {};
Definition: terminal.h:143
typename base_type::finalize_callback_type finalize_callback_type
Definition: terminal.h:157
typename base_type::setsize_callback_type setsize_callback_type
Definition: terminal.h:156
void set_callback(const send_callback_type &send_callback, const move_callback_type &move_callback, const broadcast_callback_type &bcast_callback=broadcast_callback_type{}, const setsize_callback_type &setsize_callback=setsize_callback_type{}, const finalize_callback_type &finalize_callback=finalize_callback_type{}, const prepare_send_callback_type &prepare_send_callback=prepare_send_callback_type{})
Definition: terminal.h:192
void prepare_send(const rangeT &keylist, Value &&value)
Definition: terminal.h:319
std::enable_if_t< meta::is_none_void_v< Key, Value >, void > send(const Key &key, Value &&value)
Definition: terminal.h:206
meta::detail::send_callback_t< keyT, std::decay_t< valueT > > send_callback_type
Definition: terminal.h:153
meta::detail::broadcast_callback_t< keyT, std::decay_t< valueT > > broadcast_callback_type
Definition: terminal.h:155
meta::detail::prepare_send_callback_t< keyT, std::decay_t< valueT > > prepare_send_callback_type
Definition: terminal.h:158
std::enable_if_t<!meta::is_void_v< Key >, void > sendk(const Key &key)
Definition: terminal.h:221
std::enable_if_t<!meta::is_void_v< Value >, void > sendv(Value &&value)
Definition: terminal.h:230
std::enable_if_t< meta::is_void_v< Value >, void > broadcast(const rangeT &keylist)
Definition: terminal.h:298
std::enable_if_t<!meta::is_void_v< Value >, void > broadcast(const rangeT &keylist, const Value &value)
Definition: terminal.h:257
meta::detail::move_callback_t< keyT, std::decay_t< valueT > > move_callback_type
Definition: terminal.h:154
std::enable_if_t<!meta::is_void_v< Value >, void > broadcast(const rangeT &keylist, Value &&value)
Definition: terminal.h:277
Base type for input terminals receiving messages annotated by task IDs of type keyT
Definition: terminal.h:82
std::enable_if_t<!meta::is_void_v< Key >, void > finalize(const Key &key)
Definition: terminal.h:124
std::enable_if_t< meta::is_void_v< Key >, void > set_size(std::size_t size)
Definition: terminal.h:118
finalize_callback_type finalize_callback
Definition: terminal.h:95
setsize_callback_type setsize_callback
Definition: terminal.h:94
void set_callback(const setsize_callback_type &setsize_callback=setsize_callback_type{}, const finalize_callback_type &finalize_callback=finalize_callback_type{})
Definition: terminal.h:97
meta::detail::setsize_callback_t< keyT > setsize_callback_type
Definition: terminal.h:87
static constexpr bool is_an_input_terminal
Definition: terminal.h:89
meta::detail::finalize_callback_t< keyT > finalize_callback_type
Definition: terminal.h:88
std::enable_if_t<!meta::is_void_v< Key >, void > set_size(const Key &key, std::size_t size)
Definition: terminal.h:112
std::enable_if_t< meta::is_void_v< Key >, void > finalize()
Definition: terminal.h:131
Definition: terminal.h:429
static constexpr bool is_an_output_terminal
Definition: terminal.h:436
std::enable_if_t< meta::is_void_v< Key > &&!meta::is_void_v< valueT >, void > prepare_send(const Value &value)
Definition: terminal.h:600
std::enable_if_t< meta::is_none_void_v< Key > &&!meta::is_void_v< valueT >, void > prepare_send(const rangeT &keylist, const Value &value)
Definition: terminal.h:587
std::enable_if_t< meta::is_none_void_v< Key, Value >, void > send(const Key &key, Value &&value)
Definition: terminal.h:532
std::enable_if_t< meta::is_void_v< Key > &&!meta::is_void_v< Value >, void > sendv(Value &&value)
Definition: terminal.h:487
std::enable_if_t< meta::is_all_void_v< Key, Value >, void > send()
Definition: terminal.h:514
std::enable_if_t< meta::is_none_void_v< Key > &&meta::is_void_v< valueT >, void > broadcast(const rangeT &keylist)
Definition: terminal.h:574
std::enable_if_t< meta::is_none_void_v< Key, Value >, void > broadcast(const rangeT &keylist, const Value &value)
Definition: terminal.h:561
Out()=default
std::enable_if_t<!meta::is_void_v< Key > &&meta::is_void_v< Value >, void > sendk(const Key &key)
Definition: terminal.h:475
Definition: terminal.h:373
static constexpr bool is_an_output_terminal
Definition: terminal.h:377
std::enable_if_t<!meta::is_void_v< Key >, void > finalize(const Key &key)
Definition: terminal.h:409
std::enable_if_t< meta::is_void_v< Key >, void > set_size(std::size_t size)
Definition: terminal.h:401
std::enable_if_t<!meta::is_void_v< Key >, void > set_size(const Key &key, std::size_t size)
Definition: terminal.h:393
std::enable_if_t< meta::is_void_v< Key >, void > finalize()
Definition: terminal.h:417
Definition: terminal.h:12
const std::vector< TerminalBase * > & get_connections() const
Get connections to successors.
Definition: terminal.h:107
void connect_pull(TerminalBase *predecessor)
Definition: terminal.h:66
typename input_terminals_tuple< keyT, valuesT... >::type input_terminals_tuple_t
Definition: terminal.h:354
constexpr bool is_output_terminal_v
detects whether a given type is an output terminal type
Definition: terminal.h:615
constexpr bool decays_to_output_terminal_tuple_v
Definition: terminal.h:632
constexpr bool is_input_terminal_v
detects whether a given type is an input terminal type
Definition: terminal.h:360
constexpr bool is_nonconst_lvalue_reference_to_output_terminal_tuple_v
Definition: terminal.h:637
constexpr bool is_output_terminal_tuple_v
Definition: terminal.h:629
Definition: terminal.h:25
ContainerWrapper()=default
std::function< size_t(keyT const &key)> owner
Definition: terminal.h:27
ContainerWrapper(T &t, mapperT &&mapper, keymapT &&keymap)
Definition: terminal.h:37
ContainerWrapper & operator=(const ContainerWrapper &)=default
ContainerWrapper(const ContainerWrapper &)=default
ContainerWrapper(ContainerWrapper &&)=default
std::function< valueT(keyT const &key)> get
Definition: terminal.h:26
std::tuple< ttg::In< keyT, valuesT >... > type
Definition: terminal.h:350
Definition: terminal.h:344
std::tuple< ttg::In< keyT, valuesT >... > type
Definition: terminal.h:345
Definition: terminal.h:367
Definition: terminal.h:622
Definition: meta.h:180