Commit 211c30f4 authored by Joseph Noir's avatar Joseph Noir

Reworking datagram management types

parent 9971d016
......@@ -23,12 +23,10 @@ set (LIBCAF_IO_SRCS
src/acceptor_manager.cpp
src/multiplexer.cpp
src/uri.cpp
src/endpoint.cpp
src/endpoint_manager.cpp
src/datagram_sink_manager.cpp
src/datagram_source_manager.cpp
src/datagram_sink.cpp
src/datagram_source.cpp
src/dgram_scribe.cpp
src/dgram_doorman.cpp
src/dgram_acceptor_manager.cpp
src/dgram_communicator_manager.cpp
# BASP files
src/header.cpp
src/message_type.cpp
......@@ -72,4 +70,3 @@ include_directories(. ${INCLUDE_DIRS})
if(NOT WIN32)
install(DIRECTORY caf/ DESTINATION include/caf FILES_MATCHING PATTERN "*.hpp")
endif()
This diff is collapsed.
......@@ -115,7 +115,7 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// our current processed BSAP header
basp::header hdr;
// local source
endpoint_handle hdl;
dgram_scribe_handle hdl;
// network-agnositc node identifier
node_id id;
// ports
......@@ -127,7 +127,6 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
};
void set_context(connection_handle hdl);
void set_context(endpoint_handle hdl);
// pointer to ourselves
broker* self;
......@@ -137,11 +136,9 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// keeps context information for all open connections
std::unordered_map<connection_handle, connection_context> tcp_ctx;
std::unordered_map<endpoint_handle, endpoint_context> udp_ctx;
// points to the current context for callbacks such as `make_proxy`
connection_context* this_context = nullptr;
endpoint_context* udp_context = nullptr;
// stores handles to spawn servers for other nodes; these servers
// are spawned whenever the broker learns a new node ID and try to
......
......@@ -30,10 +30,9 @@
#include "caf/io/scribe.hpp"
#include "caf/io/doorman.hpp"
#include "caf/io/endpoint.hpp"
#include "caf/io/datagram_sink.hpp"
#include "caf/io/dgram_doorman.hpp"
#include "caf/io/abstract_broker.hpp"
#include "caf/io/datagram_source.hpp"
#include "caf/io/dgram_scribe.hpp"
#include "caf/mixin/sender.hpp"
#include "caf/mixin/requester.hpp"
......
......@@ -29,8 +29,8 @@
namespace caf {
namespace io {
/// Base class for `scribe` and `doorman` as well as `datagram_source`
/// and `datagram_sink`.
/// Base class for `scribe` and `doorman` as well as `dgram_doorman`
/// and `dgram_scribe`.
/// @ingroup Broker
template <class Base, class Handle, class SysMsgType>
class broker_servant : public Base {
......@@ -106,13 +106,9 @@ protected:
std::is_same<Handle, accept_handle>::value,
acceptor_passivated_msg,
typename std::conditional<
std::is_same<Handle, endpoint_handle>::value,
endpoint_passivated_msg,
typename std::conditional<
std::is_same<Handle, datagram_sink_handle>::value,
datagram_sink_passivated_msg,
datagram_source_passivated_msg
>::type
std::is_same<Handle, dgram_scribe_handle>::value,
dgram_scribe_passivated_msg,
dgram_doorman_passivated_msg
>::type
>::type
>::type;
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* 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_IO_DATAGRAM_SINK_HPP
#define CAF_IO_DATAGRAM_SINK_HPP
#include <vector>
#include "caf/message.hpp"
#include "caf/io/broker_servant.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/datagram_sink_handle.hpp"
#include "caf/io/network/datagram_sink_manager.hpp"
namespace caf {
namespace io {
using datagram_sink_base = broker_servant<network::datagram_sink_manager,
datagram_sink_handle,
datagram_sink_msg>;
/// Manages writing to a datagram sink.
/// @ingroup Broker
class datagram_sink : public datagram_sink_base {
public:
datagram_sink(abstract_broker* parent, datagram_sink_handle hdl);
~datagram_sink();
/// Enables or disables write notifications.
virtual void ack_writes(bool enable) = 0;
/// Returns the current write buffer.
virtual std::vector<char>& wr_buf() = 0;
void datagram_sent(execution_unit* ctx, size_t num_bytes) override;
void io_failure(execution_unit* ctx, network::operation op) override;
protected:
message detach_message() override;
};
} // namespace io
} // namespace caf
#endif // CAF_IO_DATAGRAM_SINK_HPP
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_DATAGRAM_SOURCE_HPP
#define CAF_IO_DATAGRAM_SOURCE_HPP
#ifndef CAF_IO_DGRAM_DOORMAN_HPP
#define CAF_IO_DGRAM_DOORMAN_HPP
#include <vector>
......@@ -26,23 +26,23 @@
#include "caf/io/broker_servant.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/datagram_source_handle.hpp"
#include "caf/io/network/datagram_source_manager.hpp"
#include "caf/io/dgram_doorman_handle.hpp"
#include "caf/io/network/dgram_communicator_manager.hpp"
namespace caf {
namespace io {
using datagram_source_base = broker_servant<network::datagram_source_manager,
datagram_source_handle,
new_datagram_msg>;
using dgram_doorman_base = broker_servant<network::dgram_acceptor_manager,
dgram_doorman_handle,
new_endpoint_msg>;
/// Manages reading from a datagram source
/// @ingroup Broker
class datagram_source : public datagram_source_base {
class dgram_doorman : public dgram_doorman_base {
public:
datagram_source(abstract_broker* parent, datagram_source_handle hdl);
dgram_doorman(abstract_broker* parent, dgram_doorman_handle hdl);
~datagram_source();
~dgram_doorman();
/// Configure buffer size for next accepted datagram.
virtual void configure_datagram_size(size_t buf_size) = 0;
......@@ -50,10 +50,12 @@ public:
/// Returns the current input buffer.
virtual std::vector<char>& rd_buf() = 0;
bool consume(execution_unit* ctx, const void* buf, size_t besize) override;
void io_failure(execution_unit* ctx, network::operation op) override;
using dgram_doorman_base::new_endpoint;
bool new_endpoint(execution_unit* ctx, const void*, size_t num_bytes);
// needs to be launched explicitly
virtual void launch() = 0;
......@@ -64,5 +66,4 @@ protected:
} // namespace io
} // namespace caf
#endif // CAF_IO_DATAGRAM_SOURCE_HPP
#endif // CAF_IO_DGRAM_DOORMAN_HPP
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_DATAGRAM_SOURCE_HANDLE_HPP
#define CAF_IO_DATAGRAM_SOURCE_HANDLE_HPP
#ifndef CAF_IO_DGRAM_DOORMAN_HANDLE_HPP
#define CAF_IO_DGRAM_DOORMAN_HANDLE_HPP
#include <functional>
......@@ -31,40 +31,40 @@
namespace caf {
namespace io {
struct invalid_datagram_source_handle_t {
constexpr invalid_datagram_source_handle_t() {
struct invalid_dgram_doorman_handle_t {
constexpr invalid_dgram_doorman_handle_t() {
// nop
}
};
constexpr invalid_datagram_source_handle_t invalid_datagram_source_handle
= invalid_datagram_source_handle_t{};
constexpr invalid_dgram_doorman_handle_t invalid_dgram_doorman_handle
= invalid_dgram_doorman_handle_t{};
/// Generic type for identifying a datagram source.
class datagram_source_handle : public handle<datagram_source_handle,
invalid_datagram_source_handle_t> {
class dgram_doorman_handle : public handle<dgram_doorman_handle,
invalid_dgram_doorman_handle_t> {
public:
friend class handle<datagram_source_handle, invalid_datagram_source_handle_t>;
friend class handle<dgram_doorman_handle, invalid_dgram_doorman_handle_t>;
using super = handle<datagram_source_handle, invalid_datagram_source_handle_t>;
using super = handle<dgram_doorman_handle, invalid_dgram_doorman_handle_t>;
constexpr datagram_source_handle() {
constexpr dgram_doorman_handle() {
// nop
}
constexpr datagram_source_handle(const invalid_datagram_source_handle_t&) {
constexpr dgram_doorman_handle(const invalid_dgram_doorman_handle_t&) {
// nop
}
template <class Inspector>
friend typename Inspector::result_type inspect(Inspector& f,
datagram_source_handle& x) {
return f(meta::type_name("datagram_source_handle"), x.id_);
dgram_doorman_handle& x) {
return f(meta::type_name("dgram_doorman_handle"), x.id_);
}
private:
inline datagram_source_handle(int64_t handle_id) : super(handle_id) {
inline dgram_doorman_handle(int64_t handle_id) : super(handle_id) {
// nop
}
};
......@@ -75,12 +75,12 @@ private:
namespace std {
template<>
struct hash<caf::io::datagram_source_handle> {
size_t operator()(const caf::io::datagram_source_handle& hdl) const {
struct hash<caf::io::dgram_doorman_handle> {
size_t operator()(const caf::io::dgram_doorman_handle& hdl) const {
hash<int64_t> f;
return f(hdl.id());
}
};
} // namespace std
#endif // CAF_IO_DATAGRAM_SOURCE_HANDLE_HPP
#endif // CAF_IO_DGRAM_DOORMAN_HANDLE_HPP
......@@ -17,61 +17,60 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_ENDPOINT_HPP
#define CAF_IO_ENDPOINT_HPP
#ifndef CAF_IO_DGRAM_SCRIBE_HPP
#define CAF_IO_DGRAM_SCRIBE_HPP
#include <vector>
#include "caf/message.hpp"
#include "caf/io/broker_servant.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/network/endpoint_manager.hpp"
#include "caf/io/dgram_scribe_handle.hpp"
#include "caf/io/network/dgram_acceptor_manager.hpp"
namespace caf {
namespace io {
using endpoint_base = broker_servant<network::endpoint_manager, endpoint_handle,
datagram_msg>;
using dgram_scribe_base = broker_servant<network::dgram_communicator_manager,
dgram_scribe_handle,
new_datagram_msg>;
/// Manages writing and reading on a datagram endpoint.
/// Manages writing to a datagram sink.
/// @ingroup Broker
class endpoint : public endpoint_base {
class dgram_scribe : public dgram_scribe_base {
public:
endpoint(abstract_broker* parent, endpoint_handle hdl);
dgram_scribe(abstract_broker* parent, dgram_scribe_handle hdl);
~endpoint();
/// Enables or disables write notifications.
virtual void ack_writes(bool enable) = 0;
~dgram_scribe();
/// Configure buffer size for next accepted datagram.
/// Implicitly starts the read loop on first call.
virtual void configure_datagram_size(size_t buf_size) = 0;
/// Returns the current write buffer.
/// Enables or disables write notifications.
virtual void ack_writes(bool enable) = 0;
/// Returns the current output buffer.
virtual std::vector<char>& wr_buf() = 0;
/// Returns the current input buffer.
virtual std::vector<char>& rd_buf() = 0;
bool consume(execution_unit* ctx, const void* buf, size_t besize) override;
void datagram_sent(execution_unit* ctx, size_t num_bytes) override;
/// Flushes the output buffer, i.e., sends the
/// content of the buffer via the network.
virtual void flush() = 0;
void io_failure(execution_unit* ctx, network::operation op) override;
// needs to be launched explicitly, TODO: Does it?
// Can't configure_datagram_size do that?
virtual void launch() = 0;
bool consume(execution_unit*, const void*, size_t) override;
void datagram_sent(execution_unit*, size_t) override;
protected:
message detach_message() override;
};
} // namespace io
} // namespace caf
#endif // CAF_IO_ENDPOINT_HPP
#endif // CAF_IO_DGRAM_SCRIBE_HPP
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_DATAGRAM_SINK_HANDLE_HPP
#define CAF_IO_DATAGRAM_SINK_HANDLE_HPP
#ifndef CAF_IO_DGRAM_SCRIBE_HANDLE_HPP
#define CAF_IO_DGRAM_SCRIBE_HANDLE_HPP
#include <functional>
......@@ -31,36 +31,36 @@
namespace caf {
namespace io {
struct invalid_datagram_sink_handle_t {
constexpr invalid_datagram_sink_handle_t() {
struct invalid_dgram_scribe_handle_t {
constexpr invalid_dgram_scribe_handle_t() {
// nop
}
};
constexpr invalid_datagram_sink_handle_t invalid_datagram_sink_handle
= invalid_datagram_sink_handle_t{};
constexpr invalid_dgram_scribe_handle_t invalid_dgram_scribe_handle
= invalid_dgram_scribe_handle_t{};
/// Generic type for identifying datagram sink.
class datagram_sink_handle : public handle<datagram_sink_handle,
invalid_datagram_sink_handle_t> {
class dgram_scribe_handle : public handle<dgram_scribe_handle,
invalid_dgram_scribe_handle_t> {
public:
friend class handle<datagram_sink_handle, invalid_datagram_sink_handle_t>;
friend class handle<dgram_scribe_handle, invalid_dgram_scribe_handle_t>;
using super = handle<datagram_sink_handle, invalid_datagram_sink_handle_t>;
using super = handle<dgram_scribe_handle, invalid_dgram_scribe_handle_t>;
datagram_sink_handle() : port_{0} {
dgram_scribe_handle() : port_{0} {
// nop
}
datagram_sink_handle(const invalid_datagram_sink_handle_t&) : port_{0} {
dgram_scribe_handle(const invalid_dgram_scribe_handle_t&) : port_{0} {
// nop
}
template <class Inspector>
friend typename Inspector::result_type inspect(Inspector& f,
datagram_sink_handle& x) {
return f(meta::type_name("datagram_sink_handle"), x.id_);
dgram_scribe_handle& x) {
return f(meta::type_name("dgram_scribe_handle"), x.id_);
}
const std::string& host() const {
......@@ -80,7 +80,7 @@ public:
}
private:
inline datagram_sink_handle(int64_t handle_id) : super(handle_id) {
inline dgram_scribe_handle(int64_t handle_id) : super(handle_id) {
// nop
}
std::string host_;
......@@ -93,12 +93,12 @@ private:
namespace std {
template<>
struct hash<caf::io::datagram_sink_handle> {
size_t operator()(const caf::io::datagram_sink_handle& hdl) const {
struct hash<caf::io::dgram_scribe_handle> {
size_t operator()(const caf::io::dgram_scribe_handle& hdl) const {
hash<int64_t> f;
return f(hdl.id());
}
};
} // namespace std
#endif // CAF_IO_DATAGRAM_SINK_HANDLE_HPP
#endif // CAF_IO_DGRAM_SCRIBE_HANDLE_HPP
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* 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_IO_ENDPOINT_HANDLE_HPP
#define CAF_IO_ENDPOINT_HANDLE_HPP
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace caf {
namespace io {
struct invalid_endpoint_handle_t {
constexpr invalid_endpoint_handle_t() {
// nop
}
};
constexpr invalid_endpoint_handle_t invalid_endpoint_handle
= invalid_endpoint_handle_t{};
/// Generic handle type for managing local and remote datagram endpoints.
class endpoint_handle : public handle<endpoint_handle,
invalid_endpoint_handle_t> {
public:
friend class handle<endpoint_handle, invalid_endpoint_handle_t>;
using super = handle<endpoint_handle,invalid_endpoint_handle_t>;
constexpr endpoint_handle() {
// nop
}
constexpr endpoint_handle(const invalid_endpoint_handle_t&) {
// nop
}
template <class Inspector>
friend typename Inspector::result_type inspect(Inspector& f,
endpoint_handle& x) {
return f(meta::type_name("endpoint_handle"), x.id_);
}
private:
inline endpoint_handle(int64_t handle_id) : super(handle_id) {
// nop
}
};
} // namespace io
} // namespace caf
namespace std {
template<>
struct hash<caf::io::endpoint_handle> {
size_t operator()(const caf::io::endpoint_handle& hdl) const {
hash<int64_t> f;
return f(hdl.id());
}
};
} // namespace std
#endif // CAF_IO_ENDPOINT_HANDLE_HPP
......@@ -26,13 +26,12 @@ namespace io {
class scribe;
class broker;
class doorman;
class endpoint;
class middleman;
class basp_broker;
class datagram_sink;
class dgram_doorman;
class receive_policy;
class abstract_broker;
class datagram_source;
class dgram_scribe;
template <class... Sigs>
class typed_broker;
......
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_NETWORK_DATAGRAM_SOURCE_MANGER_HPP
#define CAF_IO_NETWORK_DATAGRAM_SOURCE_MANGER_HPP
#ifndef CAF_IO_NETWORK_DGRAM_ACCEPTOR_MANGER_HPP
#define CAF_IO_NETWORK_DGRAM_ACCEPTOR_MANGER_HPP
#include "caf/io/network/manager.hpp"
......@@ -28,17 +28,18 @@ namespace network {
/// A datagram source manager provides callbacks for incoming
/// datagrams as well as for error handling.
class datagram_source_manager : public manager {
class dgram_acceptor_manager : public manager {
public:
datagram_source_manager(abstract_broker* ptr);
dgram_acceptor_manager(abstract_broker* ptr);
~datagram_source_manager();
~dgram_acceptor_manager();
virtual bool new_endpoint() = 0;
};
} // namespace network
} // namespace io
} // namespace caf
#endif // CAF_IO_NETWORK_DATAGRAM_SOURCE_MANGER_HPP
#endif // CAF_IO_NETWORK_DGRAM_ACCEPTOR_MANGER_HPP
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_NETWORK_DATAGRAM_SINK_MANGER_HPP
#define CAF_IO_NETWORK_DATAGRAM_SINK_MANGER_HPP
#ifndef CAF_IO_NETWORK_DGRAM_COMMUNICATOR_MANGER_HPP
#define CAF_IO_NETWORK_DGRAM_COMMUNICATOR_MANGER_HPP
#include "caf/io/network/manager.hpp"
......@@ -28,22 +28,22 @@ namespace network {
/// A datagram manager provides callbacks for outgoing
/// datagrams as well as for error handling.
class datagram_sink_manager : public manager {
class dgram_communicator_manager : public manager {
public:
datagram_sink_manager(abstract_broker* ptr);
dgram_communicator_manager(abstract_broker* ptr);
~datagram_sink_manager();
~dgram_communicator_manager();
/// Called by the underlying I/O device whenever it received data.
/// @returns `true` if the manager accepts further reads, otherwise `false`.
virtual bool consume(execution_unit* ctx, const void* buf, size_t besize) = 0;
virtual bool consume(execution_unit*, const void*, size_t) = 0;
/// Called by the underlying I/O device whenever it sent a datagram.
virtual void datagram_sent(execution_unit* ctx, size_t num_bytes) = 0;
/// Called by the underlying I/O device whenever it sent data.
virtual void datagram_sent(execution_unit*, size_t) = 0;
};
} // namespace network
} // namespace io
} // namespace caf
#endif // CAF_IO_NETWORK_DATAGRAM_SINK_MANGER_HPP
#endif // CAF_IO_NETWORK_DGRAM_COMMUNICATOR_MANGER_HPP
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* 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_IO_NETWORK_ENDPOINT_MANAGER_HPP
#define CAF_IO_NETWORK_ENDPOINT_MANAGER_HPP
#include "caf/io/network/manager.hpp"
namespace caf {
namespace io {
namespace network {
/// An endpoint manager configures datagram endpoints and provides callbacks
/// for incoming data as well as for error handling.
class endpoint_manager : public manager {
public:
endpoint_manager(abstract_broker* ptr);
~endpoint_manager();
/// Called by the underlying I/O device whenever it received data.
/// @returns `true` if the manager accepts further reads, otherwise `false`.
virtual bool consume(execution_unit* ctx, const void* buf, size_t bsize) = 0;
/// Called by the underlying I/O device whenever it sent a datagram.
virtual void datagram_sent(execution_unit* ctx, size_t num_bytes) = 0;
};
} // namespace network
} // namespace io
} // namespace caf
#endif // CAF_IO_NETWORK_ENDPOINT_MANAGER_HPP
......@@ -32,10 +32,9 @@
#include "caf/io/fwd.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/connection_handle.hpp"
#include "caf/io/datagram_sink_handle.hpp"
#include "caf/io/datagram_source_handle.hpp"
#include "caf/io/dgram_scribe_handle.hpp"
#include "caf/io/dgram_doorman_handle.hpp"
#include "caf/io/network/protocol.hpp"
#include "caf/io/network/native_socket.hpp"
......@@ -104,77 +103,50 @@ public:
/// Tries to create a datagram sink to sent messages to `host` on given
/// `port` and returns an unbound datagram sink handle on success.
/// @threadsafe
virtual expected<datagram_sink_handle>
new_datagram_sink(const std::string& host, uint16_t port) = 0;
virtual expected<dgram_scribe_handle>
new_dgram_scribe(const std::string& host, uint16_t port) = 0;
/// Assigns an unbound datagram sink identified by `hdl` to `ptr`.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<void> assign_datagram_sink(abstract_broker* ptr,
datagram_sink_handle hdl) = 0;
virtual expected<void>
assign_dgram_scribe(abstract_broker* ptr,
dgram_scribe_handle hdl) = 0;
/// Creates a new datagram sink from a native socket handle.
/// @warning Do not call from outside the multiplexer's event loop.
virtual datagram_sink_handle add_datagram_sink(abstract_broker* ptr,
native_socket fd) = 0;
virtual dgram_scribe_handle
add_dgram_scribe(abstract_broker* ptr, native_socket fd) = 0;
/// Tries to create a datagram sink to sent messages to `host` on `port`
/// and returns a new datagram sink managing the endpoint on success.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<datagram_sink_handle>
add_datagram_sink(abstract_broker*, const std::string& host,
uint16_t port) = 0;
virtual expected<dgram_scribe_handle>
add_dgram_scribe(abstract_broker*, const std::string& host,
uint16_t port) = 0;
/// Tries to create an unbound datagram source bound to `port`, optionally
/// accepting only messages from IP address `in`.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<std::pair<datagram_source_handle, uint16_t>>
new_datagram_source(uint16_t port, const char* in = nullptr,
bool reuse_addr = false) = 0;
virtual expected<std::pair<dgram_doorman_handle, uint16_t>>
new_dgram_doorman(uint16_t port, const char* in = nullptr,
bool reuse_addr = false) = 0;
/// Assigns an unbound datagram source identified by `hdl` to `ptr`.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<void> assign_datagram_source(abstract_broker* ptr,
datagram_source_handle) = 0;
virtual expected<void> assign_dgram_doorman(abstract_broker* ptr,
dgram_doorman_handle) = 0;
/// Creates a new datagram source from a native socket handle.
/// @warning Do not call from outside the multiplexer's event loop.
virtual datagram_source_handle add_datagram_source(abstract_broker* ptr,
native_socket fd) = 0;
virtual dgram_doorman_handle add_dgram_doorman(abstract_broker* ptr,
native_socket fd) = 0;
/// Tries to create a new datagram source on port `p`, optionally
/// accepting only messages from IP address `in`.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<std::pair<datagram_source_handle, uint16_t>>
add_datagram_source(abstract_broker* ptr, uint16_t port,
const char* in = nullptr, bool reuse_addr = false) = 0;
/// TODO
virtual expected<endpoint_handle>
new_remote_endpoint(const std::string& host, uint16_t port) = 0;
/// TODO
virtual expected<std::pair<endpoint_handle, uint16_t>>
new_local_endpoint(uint16_t port = 0, const char* in = nullptr,
bool reuse_addr = false) = 0;
/// TODO
virtual expected<void> assign_endpoint(abstract_broker* ptr,
endpoint_handle hdl) = 0;
/// TODO
virtual expected<endpoint_handle> add_remote_endpoint(abstract_broker* ptr,
const std::string& host,
uint16_t port) = 0;
/// TODO
expected<std::pair<endpoint_handle, uint16_t>>
virtual add_local_endpoint(abstract_broker* ptr, uint16_t port = 0,
const char* in = nullptr,
bool reuse_addr = false) = 0;
/// TODO
virtual endpoint_handle add_endpoint(abstract_broker* ptr,
network::native_socket fd) = 0;
virtual expected<std::pair<dgram_doorman_handle, uint16_t>>
add_dgram_doorman(abstract_broker* ptr, uint16_t port,
const char* in = nullptr, bool reuse_addr = false) = 0;
/// Simple wrapper for runnables
class runnable : public resumable, public ref_counted {
......
......@@ -29,10 +29,9 @@
#include "caf/io/handle.hpp"
#include "caf/io/accept_handle.hpp"
#include "caf/io/endpoint_handle.hpp"
#include "caf/io/connection_handle.hpp"
#include "caf/io/datagram_sink_handle.hpp"
#include "caf/io/datagram_source_handle.hpp"
#include "caf/io/dgram_scribe_handle.hpp"
#include "caf/io/dgram_doorman_handle.hpp"
namespace caf {
namespace io {
......@@ -130,111 +129,61 @@ inspect(Inspector& f, acceptor_passivated_msg& x) {
}
/// Signalizes that a {@link broker} datagram sink was closed.
struct datagram_sink_closed_msg {
datagram_sink_handle handle;
struct dgram_scribe_closed_msg {
dgram_scribe_handle handle;
};
/// @relates datagram_sink_closed_msg
/// @relates dgram_scribe_closed_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, datagram_sink_closed_msg& x) {
return f(meta::type_name("datagram_sink_closed_msg"), x.handle);
inspect(Inspector& f, dgram_scribe_closed_msg& x) {
return f(meta::type_name("dgram_scribe_closed_msg"), x.handle);
}
/// Signalizes that a {@link broker} datagram source was closed.
struct datagram_source_closed_msg {
datagram_source_handle handle;
struct dgram_doorman_closed_msg {
dgram_doorman_handle handle;
};
/// @relates datagram_source_closed_msg
/// @relates dgram_doorman_closed_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, datagram_source_closed_msg& x) {
return f(meta::type_name("datagram_source_closed_msg"), x.handle);
inspect(Inspector& f, dgram_doorman_closed_msg& x) {
return f(meta::type_name("dgram_doorman_closed_msg"), x.handle);
}
/// Signalizes newly arrived datagram for a {@link broker}.
struct new_datagram_msg {
struct new_endpoint_msg {
/// Handle to the related datagram endpoint.
datagram_source_handle handle;
dgram_doorman_handle handle;
/// Buffer containing the received data.
std::vector<char> buf;
};
/// @relates new_datagram_msg
/// @relates new_endpoint_msg
template <class Inspector>
typename Inspector::result_type inspect(Inspector& f, new_datagram_msg& x) {
return f(meta::type_name("new_datagram_msg"), x.handle, x.buf);
typename Inspector::result_type inspect(Inspector& f, new_endpoint_msg& x) {
return f(meta::type_name("new_endpoint_msg"), x.handle, x.buf);
}
/// Signalizes that a datagram with a certain size has been sent.
struct datagram_sink_msg {
struct new_datagram_msg {
// Handle to the endpoint used.
datagram_sink_handle handle;
dgram_scribe_handle handle;
// number of bytes written.
uint64_t written;
};
/// @relates datagram_sink_msg
template <class Inspector>
typename Inspector::result_type inspect(Inspector& f, datagram_sink_msg& x) {
return f(meta::type_name("datagram_sink_msg"), x.handle, x.written);
}
/// Signalizes that a datagram sink has entered passive mode.
struct datagram_sink_passivated_msg {
datagram_sink_handle handle;
};
/// @relates datagram_sink_passivated_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, datagram_sink_passivated_msg& x) {
return f(meta::type_name("datagram_sink_passivated_msg"), x.handle);
}
/// Signalizes that a datagram source has entered passive mode.
struct datagram_source_passivated_msg {
datagram_source_handle handle;
};
/// @relates datagram_source_passivated_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, datagram_source_passivated_msg& x) {
return f(meta::type_name("datagram_source_passivated_msg"), x.handle);
}
/// Signalizes that a {@link broker} datagram endpoint was closed.
struct endpoint_closed_msg {
endpoint_handle handle;
};
/// @relates endpoint_closed_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, endpoint_closed_msg& x) {
return f(meta::type_name("endpoint_closed_msg"), x.handle);
}
// Signalizes newly arrived datagram for a {@link broker}.
struct datagram_msg {
/// Handle to the related datagram endpoint.
endpoint_handle handle;
/// Buffer containing the received data.
std::vector<char> buf;
};
/// @relates datagram_msg
/// @relates new_datagram_msg
template <class Inspector>
typename Inspector::result_type inspect(Inspector& f, datagram_msg& x) {
return f(meta::type_name("datagram_msg"), x.handle, x.buf);
typename Inspector::result_type inspect(Inspector& f, new_datagram_msg& x) {
return f(meta::type_name("new_datagram_msg"), x.handle, x.written);
}
/// Signalizes that a datagram with a certain size has been sent.
struct datagram_sent_msg {
// Handle to the endpoint used.
endpoint_handle handle;
dgram_scribe_handle handle;
// number of bytes written.
uint64_t written;
};
......@@ -245,16 +194,28 @@ typename Inspector::result_type inspect(Inspector& f, datagram_sent_msg& x) {
return f(meta::type_name("datagram_sent_msg"), x.handle, x.written);
}
/// Signalizes that a endpoint has entered passive mode.
struct endpoint_passivated_msg {
endpoint_handle handle;
/// Signalizes that a datagram sink has entered passive mode.
struct dgram_scribe_passivated_msg {
dgram_scribe_handle handle;
};
/// @relates dgram_scribe_passivated_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, dgram_scribe_passivated_msg& x) {
return f(meta::type_name("dgram_scribe_passivated_msg"), x.handle);
}
/// Signalizes that a datagram source has entered passive mode.
struct dgram_doorman_passivated_msg {
dgram_doorman_handle handle;
};
/// @relates endpoint_passivated_msg
/// @relates dgram_doorman_passivated_msg
template <class Inspector>
typename Inspector::result_type
inspect(Inspector& f, endpoint_passivated_msg& x) {
return f(meta::type_name("endpoint_passivated_msg"), x.handle);
inspect(Inspector& f, dgram_doorman_passivated_msg& x) {
return f(meta::type_name("dgram_doorman_passivated_msg"), x.handle);
}
} // namespace io
......
......@@ -110,14 +110,14 @@ void abstract_broker::flush(connection_handle hdl) {
x->flush();
}
void abstract_broker::ack_writes(datagram_sink_handle hdl, bool enable) {
void abstract_broker::ack_writes(dgram_scribe_handle hdl, bool enable) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(enable));
auto x = by_id(hdl);
if (x)
x->ack_writes(enable);
}
void abstract_broker::configure_datagram_size(datagram_source_handle hdl,
void abstract_broker::configure_datagram_size(dgram_doorman_handle hdl,
size_t buf_size) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(buf_size));
auto x = by_id(hdl);
......@@ -125,17 +125,17 @@ void abstract_broker::configure_datagram_size(datagram_source_handle hdl,
x->configure_datagram_size(buf_size);
}
std::vector<char>& abstract_broker::wr_buf(datagram_sink_handle hdl) {
std::vector<char>& abstract_broker::wr_buf(dgram_scribe_handle hdl) {
auto x = by_id(hdl);
if (!x) {
CAF_LOG_ERROR("tried to access wr_buf() of an unknown"
"datagram_sink_handle");
"dgram_scribe_handle");
return dummy_wr_buf_;
}
return x->wr_buf();
}
void abstract_broker::write(datagram_sink_handle hdl, size_t bs,
void abstract_broker::write(dgram_scribe_handle hdl, size_t bs,
const void* buf) {
auto& out = wr_buf(hdl);
auto first = reinterpret_cast<const char*>(buf);
......@@ -143,37 +143,6 @@ void abstract_broker::write(datagram_sink_handle hdl, size_t bs,
out.insert(out.end(), first, last);
}
void abstract_broker::ack_writes(endpoint_handle hdl, bool enable) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(enable));
auto x = by_id(hdl);
if (x)
x->ack_writes(enable);
}
void abstract_broker::configure_datagram_size(endpoint_handle hdl,
size_t buf_size) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(buf_size));
auto x = by_id(hdl);
if (x)
x->configure_datagram_size(buf_size);
}
std::vector<char>& abstract_broker::wr_buf(endpoint_handle hdl) {
auto x = by_id(hdl);
if (!x) {
CAF_LOG_ERROR("tried to access wr_buf() of an unknown endpoint_handle");
return dummy_wr_buf_;
}
return x->wr_buf();
}
void abstract_broker::write(endpoint_handle hdl, size_t bs, const void* buf) {
auto& out = wr_buf(hdl);
auto first = reinterpret_cast<const char*>(buf);
auto last = first + bs;
out.insert(out.end(), first, last);
}
std::vector<connection_handle> abstract_broker::connections() const {
std::vector<connection_handle> result;
result.reserve(scribes_.size());
......@@ -228,80 +197,51 @@ abstract_broker::add_tcp_doorman(network::native_socket fd) {
return backend().add_tcp_doorman(this, fd);
}
void abstract_broker::add_datagram_sink(const intrusive_ptr<datagram_sink>& ptr) {
datagram_sinks_.emplace(ptr->hdl(), ptr);
void abstract_broker::add_dgram_scribe(const intrusive_ptr<dgram_scribe>& ptr) {
dgram_scribes_.emplace(ptr->hdl(), ptr);
}
expected<datagram_sink_handle>
abstract_broker::add_datagram_sink(const std::string& hostname, uint16_t port) {
expected<dgram_scribe_handle>
abstract_broker::add_dgram_scribe(const std::string& hostname, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(hostname) << CAF_ARG(port));
return backend().add_datagram_sink(this, hostname, port);
return backend().add_dgram_scribe(this, hostname, port);
}
expected<void> abstract_broker::assign_datagram_sink(datagram_sink_handle hdl) {
expected<void> abstract_broker::assign_dgram_scribe(dgram_scribe_handle hdl) {
CAF_LOG_TRACE(CAF_ARG(hdl));
return backend().assign_datagram_sink(this, hdl);
return backend().assign_dgram_scribe(this, hdl);
}
expected<datagram_sink_handle>
abstract_broker::add_datagram_sink(network::native_socket fd) {
expected<dgram_scribe_handle>
abstract_broker::add_dgram_scribe(network::native_socket fd) {
CAF_LOG_TRACE(CAF_ARG(fd));
return backend().add_datagram_sink(this, fd);
return backend().add_dgram_scribe(this, fd);
}
void
abstract_broker::add_datagram_source(const intrusive_ptr<datagram_source>& ptr) {
datagram_sources_.emplace(ptr->hdl(), ptr);
abstract_broker::add_dgram_doorman(const intrusive_ptr<dgram_doorman>& ptr) {
dgram_doormans_.emplace(ptr->hdl(), ptr);
ptr->launch();
// TODO: some launching of things?
}
expected<std::pair<datagram_source_handle, uint16_t>>
abstract_broker::add_datagram_source(uint16_t port, const char* in,
expected<std::pair<dgram_doorman_handle, uint16_t>>
abstract_broker::add_dgram_doorman(uint16_t port, const char* in,
bool reuse_addr) {
CAF_LOG_TRACE(CAF_ARG(port) << CAF_ARG(in) << CAF_ARG(reuse_addr));
return backend().add_datagram_source(this, port, in, reuse_addr);
return backend().add_dgram_doorman(this, port, in, reuse_addr);
}
expected<void>
abstract_broker::assign_datagram_source(datagram_source_handle hdl) {
CAF_LOG_TRACE(CAF_ARG(hdl));
return backend().assign_datagram_source(this, hdl);
}
expected<datagram_source_handle>
abstract_broker::add_datagram_source(network::native_socket fd) {
CAF_LOG_TRACE(CAF_ARG(fd));
return backend().add_datagram_source(this, fd);
}
void abstract_broker::add_endpoint(const intrusive_ptr<endpoint>& ptr) {
endpoints_.emplace(ptr->hdl(), ptr);
ptr->launch(); // TODO: Is this required?
}
expected<void> abstract_broker::assign_endpoint(endpoint_handle hdl) {
abstract_broker::assign_dgram_doorman(dgram_doorman_handle hdl) {
CAF_LOG_TRACE(CAF_ARG(hdl));
return backend().assign_endpoint(this, hdl);
}
expected<endpoint_handle>
abstract_broker::add_remote_endpoint(const std::string& host, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(host) << CAF_ARG(port));
return backend().add_remote_endpoint(this, host, port);
return backend().assign_dgram_doorman(this, hdl);
}
expected<std::pair<endpoint_handle, uint16_t>>
abstract_broker::add_local_endpoint(uint16_t port, const char* in,
bool reuse_addr) {
CAF_LOG_TRACE(CAF_ARG(port) << CAF_ARG(in) << CAF_ARG(reuse_addr));
return backend().add_local_endpoint(this, port, in, reuse_addr);
}
expected<endpoint_handle>
abstract_broker::add_endpoint(network::native_socket fd) {
expected<dgram_doorman_handle>
abstract_broker::add_dgram_doorman(network::native_socket fd) {
CAF_LOG_TRACE(CAF_ARG(fd));
return backend().add_endpoint(this, fd);
return backend().add_dgram_doorman(this, fd);
}
std::string abstract_broker::remote_addr(connection_handle hdl) {
......@@ -324,19 +264,19 @@ uint16_t abstract_broker::local_port(accept_handle hdl) {
return i != doormen_.end() ? i->second->port() : 0;
}
std::string abstract_broker::remote_addr(datagram_sink_handle hdl) {
auto i = datagram_sinks_.find(hdl);
return i != datagram_sinks_.end() ? i->second->addr() : std::string{};
std::string abstract_broker::remote_addr(dgram_scribe_handle hdl) {
auto i = dgram_scribes_.find(hdl);
return i != dgram_scribes_.end() ? i->second->addr() : std::string{};
}
uint16_t abstract_broker::remote_port(datagram_sink_handle hdl) {
auto i = datagram_sinks_.find(hdl);
return i != datagram_sinks_.end() ? i->second->port() : 0;
uint16_t abstract_broker::remote_port(dgram_scribe_handle hdl) {
auto i = dgram_scribes_.find(hdl);
return i != dgram_scribes_.end() ? i->second->port() : 0;
}
uint16_t abstract_broker::local_port(datagram_source_handle hdl) {
auto i = datagram_sources_.find(hdl);
return i != datagram_sources_.end() ? i->second->port() : 0;
uint16_t abstract_broker::local_port(dgram_doorman_handle hdl) {
auto i = dgram_doormans_.find(hdl);
return i != dgram_doormans_.end() ? i->second->port() : 0;
}
accept_handle abstract_broker::hdl_by_port(uint16_t port) {
......@@ -356,9 +296,13 @@ void abstract_broker::close_all() {
// stop_reading will remove the scribe from scribes_
scribes_.begin()->second->stop_reading();
}
while (!endpoints_.empty()) {
// stop_reading will remove the enpoint from endpoints_
endpoints_.begin()->second->stop_reading();
while (!dgram_doormans_.empty()) {
// stop_reading will remove the scribe from dgram_doormans_
dgram_doormans_.begin()->second->stop_reading();
}
while (!dgram_scribes_.empty()) {
// stop_reading will remove the scribe from dgram_scribes_
dgram_scribes_.begin()->second->stop_reading();
}
}
......
......@@ -465,21 +465,6 @@ void basp_broker_state::set_context(connection_handle hdl) {
this_context = &i->second;
}
void basp_broker_state::set_context(endpoint_handle hdl) {
CAF_LOG_TRACE(CAF_ARG(hdl));
auto i = udp_ctx.find(hdl);
if (i == udp_ctx.end()) {
CAF_LOG_INFO("create new BASP context:" << CAF_ARG(hdl));
i = udp_ctx.emplace(hdl,
endpoint_context{
basp::header{basp::message_type::client_handshake, 0,
0, 0, none, none,
invalid_actor_id, invalid_actor_id},
hdl, none, 0, 0, none}).first;
}
udp_context = &i->second;
}
/******************************************************************************
* basp_broker *
******************************************************************************/
......@@ -537,10 +522,11 @@ behavior basp_broker::make_behavior() {
}
},
// received from underlying broker implementation
[=](datagram_msg& msg) {
[=](new_datagram_msg& msg) {
CAF_LOG_TRACE(CAF_ARG(msg.handle));
CAF_LOG_DEBUG("Received new_datagram_msg: " << CAF_ARG(msg));
state.set_context(msg.handle);
static_cast<void>(msg);
// state.set_context(msg.handle);
// auto& ctx = *state.udp_context;
//auto next = state.instance.handle(context(), msg, ctx.hdr, ...);
// TODO: implement this
......@@ -645,14 +631,14 @@ behavior basp_broker::make_behavior() {
<< CAF_ARG(whom));
}
},
[=](publish_atom, datagram_source_handle hdl, uint16_t port,
[=](publish_atom, dgram_doorman_handle hdl, uint16_t port,
const strong_actor_ptr& whom, std::set<std::string>& sigs) {
CAF_LOG_TRACE(CAF_ARG(hdl.id()) << CAF_ARG(whom) << CAF_ARG(port));
if (hdl.invalid()) {
CAF_LOG_WARNING("invalid handle");
return;
}
auto res = assign_datagram_source(hdl);
auto res = assign_dgram_doorman(hdl);
if (res) {
if (whom)
system().registry().put(whom->id(), whom);
......@@ -680,13 +666,13 @@ behavior basp_broker::make_behavior() {
rp.deliver(std::move(res.error()));
}
},
[=](connect_atom, endpoint_handle hdl, uint16_t port) {
[=](connect_atom, dgram_scribe_handle hdl, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(hdl.id()));
static_cast<void>(hdl);
static_cast<void>(port);
/*
auto rp = make_response_promise();
auto res = assign_datagram_sink(hdl);
auto res = assign_dgram_scribe(hdl);
if (res) {
auto& ctx = state.udp_ctx[hdl];
ctx.sink = hdl;
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* 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. *
******************************************************************************/
#include "caf/io/datagram_source.hpp"
#include "caf/logger.hpp"
namespace caf {
namespace io {
datagram_source::datagram_source(abstract_broker* parent,
datagram_source_handle hdl)
: datagram_source_base(parent, hdl) {
// nop
}
datagram_source::~datagram_source() {
CAF_LOG_TRACE("");
}
message datagram_source::detach_message() {
return make_message(datagram_source_closed_msg{hdl()});
}
bool datagram_source::consume(execution_unit* ctx, const void*,
size_t num_bytes) {
CAF_ASSERT(ctx != nullptr);
CAF_LOG_TRACE(CAF_ARG(num_bytes));
if (detached())
// we are already disconnected from the broker while the multiplexer
// did not yet remove the socket, this can happen if an I/O event causes
// the broker to call close_all() while the pollset contained
// further activities for the broker
return false;
// keep a strong reference to our parent until we leave scope
// to avoid UB when becoming detached during invocation
auto guard = parent_;
auto& buf = rd_buf();
CAF_ASSERT(buf.size() >= num_bytes);
// make sure size is correct, swap into message, and then call client
buf.resize(num_bytes);
auto& msg_buf = msg().buf;
msg_buf.swap(buf);
auto result = invoke_mailbox_element(ctx);
// swap buffer back to stream and implicitly flush wr_buf()
msg_buf.swap(buf);
// flush(); // <-- TODO: here from scribe, not sure why?
return result;
}
void datagram_source::io_failure(execution_unit* ctx, network::operation op) {
CAF_LOG_TRACE(CAF_ARG(hdl()) << CAF_ARG(op));
// keep compiler happy when compiling w/o logging
static_cast<void>(op);
detach(ctx, true);
}
} // namespace io
} // namespace caf
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2016 *
* 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. *
******************************************************************************/
#include "caf/io/network/datagram_source_manager.hpp"
namespace caf {
namespace io {
namespace network {
datagram_source_manager::datagram_source_manager(abstract_broker* ptr)
: manager(ptr) {
// nop
}
datagram_source_manager::~datagram_source_manager() {
// nop
}
} // namespace network
} // namespace io
} // namespace caf
This diff is collapsed.
......@@ -17,18 +17,18 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/network/datagram_sink_manager.hpp"
#include "caf/io/network/dgram_acceptor_manager.hpp"
namespace caf {
namespace io {
namespace network {
datagram_sink_manager::datagram_sink_manager(abstract_broker* ptr)
dgram_acceptor_manager::dgram_acceptor_manager(abstract_broker* ptr)
: manager(ptr) {
// nop
}
datagram_sink_manager::~datagram_sink_manager() {
dgram_acceptor_manager::~dgram_acceptor_manager() {
// nop
}
......
......@@ -17,18 +17,18 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/network/endpoint_manager.hpp"
#include "caf/io/network/dgram_communicator_manager.hpp"
namespace caf {
namespace io {
namespace network {
endpoint_manager::endpoint_manager(abstract_broker* ptr)
dgram_communicator_manager::dgram_communicator_manager(abstract_broker* ptr)
: manager(ptr) {
// nop
}
endpoint_manager::~endpoint_manager() {
dgram_communicator_manager::~dgram_communicator_manager() {
// nop
}
......
......@@ -17,46 +17,39 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/datagram_sink.hpp"
#include "caf/io/dgram_doorman.hpp"
#include "caf/logger.hpp"
namespace caf {
namespace io {
datagram_sink::datagram_sink(abstract_broker* parent, datagram_sink_handle hdl)
: datagram_sink_base(parent, hdl) {
dgram_doorman::dgram_doorman(abstract_broker* parent,
dgram_doorman_handle hdl)
: dgram_doorman_base(parent, hdl) {
// nop
}
datagram_sink::~datagram_sink() {
dgram_doorman::~dgram_doorman() {
CAF_LOG_TRACE("");
}
message datagram_sink::detach_message() {
return make_message(datagram_sink_closed_msg{hdl()});
message dgram_doorman::detach_message() {
return make_message(dgram_doorman_closed_msg{hdl()});
}
void datagram_sink::datagram_sent(execution_unit*, size_t) {
CAF_LOG_TRACE(CAF_ARG(written));
/*
if (detached())
return;
using sent_t = datagram_sent_msg;
using tmp_t = mailbox_element_vals<datagram_sent_msg>;
tmp_t tmp{strong_actor_ptr{}, message_id::make(),
mailbox_element::forwarding_stack{},
sent_t{hdl(), written}};
invoke_mailbox_element_impl(ctx, tmp);
*/
}
void datagram_sink::io_failure(execution_unit* ctx, network::operation op) {
void dgram_doorman::io_failure(execution_unit* ctx, network::operation op) {
CAF_LOG_TRACE(CAF_ARG(hdl()) << CAF_ARG(op));
// keep compiler happy when compiling w/o logging
static_cast<void>(op);
detach(ctx, true);
}
bool dgram_doorman::new_endpoint(execution_unit* ctx, const void* buf,
size_t besize) {
// TODO: implement me!
return false;
}
} // namespace io
} // namespace caf
......@@ -17,28 +17,28 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/endpoint.hpp"
#include "caf/io/dgram_scribe.hpp"
#include "caf/logger.hpp"
namespace caf {
namespace io {
endpoint::endpoint(abstract_broker* parent, endpoint_handle hdl)
: endpoint_base(parent, hdl) {
dgram_scribe::dgram_scribe(abstract_broker* parent, dgram_scribe_handle hdl)
: dgram_scribe_base(parent, hdl) {
// nop
}
endpoint::~endpoint() {
dgram_scribe::~dgram_scribe() {
CAF_LOG_TRACE("");
}
message endpoint::detach_message() {
return make_message(endpoint_closed_msg{hdl()});
message dgram_scribe::detach_message() {
return make_message(dgram_scribe_closed_msg{hdl()});
}
bool endpoint::consume(execution_unit* ctx, const void*, size_t num_bytes) {
bool dgram_scribe::consume(execution_unit* ctx, const void*,
size_t num_bytes) {
CAF_ASSERT(ctx != nullptr);
CAF_LOG_TRACE(CAF_ARG(num_bytes));
if (detached())
......@@ -63,7 +63,7 @@ bool endpoint::consume(execution_unit* ctx, const void*, size_t num_bytes) {
return result;
}
void endpoint::datagram_sent(execution_unit* ctx, size_t written) {
void dgram_scribe::datagram_sent(execution_unit* ctx, size_t written) {
CAF_LOG_TRACE(CAF_ARG(written));
if (detached())
return;
......@@ -75,7 +75,7 @@ void endpoint::datagram_sent(execution_unit* ctx, size_t written) {
invoke_mailbox_element_impl(ctx, tmp);
}
void endpoint::io_failure(execution_unit* ctx, network::operation op) {
void dgram_scribe::io_failure(execution_unit* ctx, network::operation op) {
CAF_LOG_TRACE(CAF_ARG(hdl()) << CAF_ARG(op));
// keep compiler happy when compiling w/o logging
static_cast<void>(op);
......
This diff is collapsed.
......@@ -72,7 +72,7 @@ behavior make_pong_behavior() {
} // namespace <anonymous>
CAF_TEST_FIXTURE_SCOPE(datagrams, fixture)
/*
CAF_TEST(test_remote_endpoint) {
auto& mp = client_side_mm.backend();
auto hdl = client_side_mm.named_broker<basp_broker>(atom("BASP"));
......@@ -134,5 +134,5 @@ CAF_TEST(test_datagram_remote_actor) {
anon_send_exit(pong, exit_reason::user_shutdown);
}
*/
CAF_TEST_FIXTURE_SCOPE_END()
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