Commit 7fec52d0 authored by Dominik Charousset's avatar Dominik Charousset Committed by Dominik Charousset

Add test scaffold for new streaming infrastructure

parent d6f6bfa3
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2017 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_OVERLOAD_HPP
#define CAF_DETAIL_OVERLOAD_HPP
namespace caf {
namespace detail {
template <class... Fs>
struct overload;
template <class F>
struct overload<F> : F {
using F::operator();
overload(F f) : F(f) {
// nop
}
};
template <class F, class... Fs>
struct overload<F, Fs...> : F, overload<Fs...> {
using F::operator();
using overload<Fs...>::operator();
overload(F f, Fs... fs) : F(f), overload<Fs...>(fs...) {
// nop
}
};
template <class... Fs>
overload<Fs...> make_overload(Fs... fs) {
return {fs...};
}
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_OVERLOAD_HPP
......@@ -20,11 +20,50 @@
#define CAF_STREAM_SLOT_HPP
#include <cstdint>
#include <tuple>
#include "caf/detail/comparable.hpp"
namespace caf {
/// Actor-specific identifier for stream traffic.
using stream_slot = uint64_t;
/// Identifies a single stream path in the same way a TCP port identifies a
/// connection over IP.
using stream_slot = uint16_t;
/// Maps two `stream_slot` values into a pair for storing sender and receiver
/// slot information.
struct stream_slots : detail::comparable<stream_slots>{
stream_slot sender;
stream_slot receiver;
// -- constructors, destructors, and assignment operators --------------------
constexpr stream_slots(stream_slot sender_slot, stream_slot receiver_slot)
: sender(sender_slot),
receiver(receiver_slot) {
// nop
}
// -- observers --------------------------------------------------------------
/// Returns an inverted pair, i.e., swaps sender and receiver slot.
constexpr stream_slots invert() const {
return {receiver, sender};
}
inline int_fast32_t compare(stream_slots other) const noexcept {
static_assert(sizeof(stream_slots) == sizeof(int32_t),
"sizeof(stream_slots) != sizeof(int32_t)");
return reinterpret_cast<const int32_t&>(*this)
- reinterpret_cast<int32_t&>(other);
}
};
/// @relates stream_slots
template <class Inspector>
typename Inspector::result_type inspect(Inspector& f, stream_slots& x) {
return f(std::tie(x.sender, x.receiver));
}
} // namespace caf
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment