Unverified Commit 9eac8a21 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #65

Port message-rework changes to incubator
parents 87d4ebdd d2bf0a64
# -- project setup ------------------------------------------------------------- # -- project setup -------------------------------------------------------------
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(caf_incubator C CXX) project(caf_incubator CXX)
# -- project options ----------------------------------------------------------- # -- project options -----------------------------------------------------------
...@@ -10,12 +10,10 @@ option(BUILD_SHARED_LIBS "Build all modules as shared library" ON) ...@@ -10,12 +10,10 @@ option(BUILD_SHARED_LIBS "Build all modules as shared library" ON)
# -- includes ------------------------------------------------------------------ # -- includes ------------------------------------------------------------------
include(CMakePackageConfigHelpers) # For creating .cmake files include(CMakePackageConfigHelpers) # For creating .cmake files
include(CheckCSourceCompiles) # Check whether compiler works include(CheckCXXSourceCompiles) # Check wether compiler works
include(CheckCSourceRuns) # Check whether compiler produces binaries
include(GNUInstallDirs) # Sets default install paths include(GNUInstallDirs) # Sets default install paths
include(GenerateExportHeader) # Auto-generates dllexport macros include(GenerateExportHeader) # Auto-generates dllexport macros
# -- project-specific CMake settings ------------------------------------------- # -- project-specific CMake settings -------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
...@@ -165,19 +163,6 @@ endif() ...@@ -165,19 +163,6 @@ endif()
# utility functions # # utility functions #
################################################################################ ################################################################################
# Appends `str` to the variable named `var` with a whitespace as separator.
# Suppresses a leading whitespace if the variable is empty and does nothing if
# `str` is empty.
function(build_string var str)
if(NOT str STREQUAL "")
if("${${var}}" STREQUAL "")
set("${var}" "${str}" PARENT_SCOPE)
else()
set("${var}" "${${var}} ${str}" PARENT_SCOPE)
endif()
endif()
endfunction(build_string)
# Forces `var` to 'no' if the content of the variables evaluates to false. # Forces `var` to 'no' if the content of the variables evaluates to false.
function(pretty_no var) function(pretty_no var)
if(NOT "${${var}}") if(NOT "${${var}}")
...@@ -266,42 +251,6 @@ endif() ...@@ -266,42 +251,6 @@ endif()
# -- compiler setup ------------------------------------------------------------ # -- compiler setup ------------------------------------------------------------
# Enable a ton of warnings if --more-clang-warnings is used.
if(CAF_MORE_WARNINGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WFLAGS "-Weverything -Wno-c++98-compat -Wno-padded "
"-Wno-documentation-unknown-command -Wno-exit-time-destructors "
"-Wno-global-constructors -Wno-missing-prototypes "
"-Wno-c++98-compat-pedantic -Wno-unused-member-function "
"-Wno-unused-const-variable -Wno-switch-enum "
"-Wno-abstract-vbase-init -Wno-shadow "
"-Wno-missing-noreturn -Wno-covered-switch-default")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(WFLAGS "-Waddress -Wall -Warray-bounds "
"-Wattributes -Wbuiltin-macro-redefined -Wcast-align "
"-Wcast-qual -Wchar-subscripts -Wclobbered -Wcomment "
"-Wconversion -Wconversion-null -Wcoverage-mismatch "
"-Wcpp -Wdelete-non-virtual-dtor -Wdeprecated "
"-Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion "
"-Wempty-body -Wendif-labels -Wenum-compare -Wextra "
"-Wfloat-equal -Wformat -Wfree-nonheap-object "
"-Wignored-qualifiers -Winit-self "
"-Winline -Wint-to-pointer-cast -Winvalid-memory-model "
"-Winvalid-offsetof -Wlogical-op -Wmain -Wmaybe-uninitialized "
"-Wmissing-braces -Wmultichar "
"-Wnarrowing -Wnoexcept -Wnon-template-friend "
"-Wnon-virtual-dtor -Wnonnull -Woverflow "
"-Woverlength-strings -Wparentheses "
"-Wpmf-conversions -Wpointer-arith -Wreorder "
"-Wreturn-type -Wsequence-point "
"-Wsign-compare -Wswitch -Wtype-limits -Wundef "
"-Wuninitialized -Wunused -Wvla -Wwrite-strings")
endif()
# convert CMake list to a single string, erasing the ";" separators
string(REPLACE ";" "" WFLAGS_STR ${WFLAGS})
build_string("EXTRA_FLAGS" "${WFLAGS_STR}")
endif()
# Enable ASAN if requested by the user. # Enable ASAN if requested by the user.
if(CAF_SANITIZERS) if(CAF_SANITIZERS)
add_compile_options("-fsanitize=${CAF_SANITIZERS}" add_compile_options("-fsanitize=${CAF_SANITIZERS}"
...@@ -311,18 +260,18 @@ endif() ...@@ -311,18 +260,18 @@ endif()
# -pthread is ignored on MacOSX but required on other platforms # -pthread is ignored on MacOSX but required on other platforms
if(NOT APPLE AND NOT WIN32) if(NOT APPLE AND NOT WIN32)
build_string("EXTRA_FLAGS" "-pthread") add_compile_options(-pthread)
list(APPEND CAF_EXTRA_LDFLAGS "-pthread")
endif() endif()
# -fPIC generates warnings on MinGW and Cygwin plus extra setup steps needed on MinGW # -fPIC generates warnings on MinGW and Cygwin plus extra setup steps needed on MinGW
if(MINGW) if(MINGW)
add_definitions(-D_WIN32_WINNT=0x0600) add_definitions(-D_WIN32_WINNT=0x0600 -DWIN32)
add_definitions(-DWIN32)
list(APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi) list(APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi)
# build static to avoid runtime dependencies to GCC libraries # build static to avoid runtime dependencies to GCC libraries
build_string("EXTRA_FLAGS" "-static") add_compile_options(-static)
elseif(CYGWIN) elseif(CYGWIN)
build_string("EXTRA_FLAGS" "-U__STRICT_ANSI__") add_compile_options(-U__STRICT_ANSI__)
endif() endif()
# Add Windows-specific linker flags. # Add Windows-specific linker flags.
...@@ -338,45 +287,12 @@ endif() ...@@ -338,45 +287,12 @@ endif()
# Add iOS target if requested by user. # Add iOS target if requested by user.
if(CAF_IOS_DEPLOYMENT_TARGET) if(CAF_IOS_DEPLOYMENT_TARGET)
if(CAF_OSX_SYSROOT STREQUAL "iphonesimulator") if(CAF_OSX_SYSROOT STREQUAL "iphonesimulator")
build_string("EXTRA_FLAGS" add_compile_options("-mios-simulator-version-min=${CAF_IOS_DEPLOYMENT_TARGET}")
"-mios-simulator-version-min=${CAF_IOS_DEPLOYMENT_TARGET}")
else() else()
build_string("EXTRA_FLAGS" add_compile_options("-miphoneos-version-min=${CAF_IOS_DEPLOYMENT_TARGET}")
"-miphoneos-version-min=${CAF_IOS_DEPLOYMENT_TARGET}")
endif() endif()
endif() endif()
# -- check if the user provided CXXFLAGS, set defaults otherwise ---------------
if(NOT CMAKE_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "-Wextra -Wall -pedantic ${EXTRA_FLAGS}")
endif()
if(NOT CMAKE_CXX_FLAGS_DEBUG)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
endif()
if(NOT CMAKE_CXX_FLAGS_MINSIZEREL)
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
endif()
if(NOT CMAKE_CXX_FLAGS_RELEASE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
endif()
if(NOT CMAKE_CXX_FLAGS_RELWITHDEBINFO)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -fno-omit-frame-pointer")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
# needed by subprojects
if (DEFINED CMAKE_LD_LIBS)
list(APPEND ${CMAKE_LD_LIBS})
endif()
# -- install targets ----------------------------------------------------------- # -- install targets -----------------------------------------------------------
# Process cmake_uninstall.cmake.in. # Process cmake_uninstall.cmake.in.
...@@ -435,12 +351,7 @@ endmacro() ...@@ -435,12 +351,7 @@ endmacro()
# Invert CAF_NO_* variables for nicer output. # Invert CAF_NO_* variables for nicer output.
invertYesNo(CAF_NO_UNIT_TESTS CAF_BUILD_UNIT_TESTS) invertYesNo(CAF_NO_UNIT_TESTS CAF_BUILD_UNIT_TESTS)
get_property(all_cxx_flags DIRECTORY PROPERTY COMPILE_OPTIONS)
# Collect all compiler flags.
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
set(ALL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_BUILD_TYPE}}")
set(ALL_LD_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CAF_EXTRA_LDFLAGS}")
string(STRIP "${ALL_LD_FLAGS}" ALL_LD_FLAGS)
# Print summary. # Print summary.
if(NOT CAF_NO_SUMMARY) if(NOT CAF_NO_SUMMARY)
...@@ -452,7 +363,7 @@ if(NOT CAF_NO_SUMMARY) ...@@ -452,7 +363,7 @@ if(NOT CAF_NO_SUMMARY)
"\nBuild static runtime: ${CAF_BUILD_STATIC_RUNTIME}" "\nBuild static runtime: ${CAF_BUILD_STATIC_RUNTIME}"
"\n" "\n"
"\nCXX: ${CMAKE_CXX_COMPILER}" "\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${ALL_CXX_FLAGS}" "\nCXXFLAGS: ${all_cxx_flags}"
"\nLINKER_FLAGS (shared): ${ALL_LD_FLAGS}" "\nLINKER_FLAGS (shared): ${ALL_LD_FLAGS}"
"\n" "\n"
"\nSource directory: ${CMAKE_CURRENT_SOURCE_DIR}" "\nSource directory: ${CMAKE_CURRENT_SOURCE_DIR}"
......
#include "caf/test/unit_test_impl.hpp" #define CAF_TEST_NO_MAIN
#include "incubator-test.hpp"
int main(int argc, char** argv) {
caf::core::init_global_meta_objects();
caf::init_global_meta_objects<caf::id_block::incubator_test>();
return caf::test::main(argc, argv);
}
#pragma once
#include <vector>
#include "caf/fwd.hpp"
#include "caf/stream.hpp"
#include "caf/test/dsl.hpp"
#include "caf/test/unit_test_impl.hpp"
#include "caf/type_id.hpp"
CAF_BEGIN_TYPE_ID_BLOCK(incubator_test, caf::first_custom_type_id)
CAF_ADD_TYPE_ID(incubator_test, (caf::stream<int>) )
CAF_ADD_TYPE_ID(incubator_test, (std::vector<int>) )
CAF_END_TYPE_ID_BLOCK(incubator_test)
...@@ -2,15 +2,6 @@ ...@@ -2,15 +2,6 @@
# Convenience wrapper for easily viewing/setting options that # Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize. # the project's CMake scripts will recognize.
# check for `cmake` command
type cmake > /dev/null 2>&1 || {
echo "\
This package requires CMake, please install it first, then you may
use this configure script to access CMake equivalent functionality.\
" >&2;
exit 1;
}
command="$0 $*" command="$0 $*"
dirname_0=`dirname $0` dirname_0=`dirname $0`
sourcedir=`cd $dirname_0 && pwd` sourcedir=`cd $dirname_0 && pwd`
...@@ -19,20 +10,20 @@ usage="\ ...@@ -19,20 +10,20 @@ usage="\
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
Build Options: Build Options:
--cmake=PATH set a custom path to the CMake binary
--generator=GENERATOR set CMake generator (see cmake --help) --generator=GENERATOR set CMake generator (see cmake --help)
--build-type=TYPE set CMake build type [RelWithDebInfo]: --build-type=TYPE set CMake build type [RelWithDebInfo]:
- Debug: debugging flags enabled - Debug: debugging flags enabled
- MinSizeRel: minimal output size - MinSizeRel: minimal output size
- Release: optimizations on, debugging off - Release: optimizations on, debugging off
- RelWithDebInfo: release flags plus debugging - RelWithDebInfo: release flags plus debugging
--extra-flags=STRING additional compiler flags --extra-flags=STRING additional compiler flags (sets CMAKE_CXX_FLAGS)
--build-dir=DIR place build files in directory [build] --build-dir=DIR place build files in directory [build]
--bin-dir=DIR executable directory [build/bin] --bin-dir=DIR executable directory [build/bin]
--lib-dir=DIR library directory [build/lib] --lib-dir=DIR library directory [build/lib]
--build-static build as static and shared library --build-static build as static and shared library
--build-static-only build as static library only --build-static-only build as static library only
--static-runtime build with static C++ runtime --static-runtime build with static C++ runtime
--more-warnings enables most warnings
--no-compiler-check disable compiler version check --no-compiler-check disable compiler version check
--no-auto-libc++ do not automatically enable libc++ for Clang --no-auto-libc++ do not automatically enable libc++ for Clang
...@@ -111,6 +102,9 @@ while [ $# -ne 0 ]; do ...@@ -111,6 +102,9 @@ while [ $# -ne 0 ]; do
echo "${usage}" 1>&2 echo "${usage}" 1>&2
exit 1 exit 1
;; ;;
--cmake=*)
CMakeCommand="$optarg"
;;
--generator=*) --generator=*)
CMakeGenerator="$optarg" CMakeGenerator="$optarg"
;; ;;
...@@ -120,9 +114,6 @@ while [ $# -ne 0 ]; do ...@@ -120,9 +114,6 @@ while [ $# -ne 0 ]; do
--with-sanitizers=*) --with-sanitizers=*)
append_cache_entry CAF_SANITIZERS STRING "$optarg" append_cache_entry CAF_SANITIZERS STRING "$optarg"
;; ;;
--more-warnings)
append_cache_entry CAF_MORE_WARNINGS BOOL yes
;;
--no-compiler-check) --no-compiler-check)
append_cache_entry CAF_NO_COMPILER_CHECK BOOL yes append_cache_entry CAF_NO_COMPILER_CHECK BOOL yes
;; ;;
...@@ -143,7 +134,7 @@ while [ $# -ne 0 ]; do ...@@ -143,7 +134,7 @@ while [ $# -ne 0 ]; do
append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg" append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg"
;; ;;
--extra-flags=*) --extra-flags=*)
append_cache_entry EXTRA_FLAGS STRING "$optarg" append_cache_entry CMAKE_CXX_FLAGS STRING "$optarg"
;; ;;
--build-dir=*) --build-dir=*)
builddir="$optarg" builddir="$optarg"
...@@ -186,6 +177,21 @@ done ...@@ -186,6 +177,21 @@ done
# -- CMake setup --------------------------------------------------------------- # -- CMake setup ---------------------------------------------------------------
# Check for `cmake` command.
if [ -z "$CMakeCommand" ]; then
# prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL)
if command -v cmake3 >/dev/null 2>&1 ; then
CMakeCommand="cmake3"
elif command -v cmake >/dev/null 2>&1 ; then
CMakeCommand="cmake"
else
echo "This package requires CMake, please install it first."
echo "Then you may use this script to configure the CMake build."
echo "Note: pass --cmake=PATH to use cmake in non-standard locations."
exit 1;
fi
fi
CMakeDefaultCache=$CMakeCacheEntries CMakeDefaultCache=$CMakeCacheEntries
CMakeCacheEntries=$CMakeDefaultCache CMakeCacheEntries=$CMakeDefaultCache
...@@ -214,9 +220,9 @@ fi ...@@ -214,9 +220,9 @@ fi
cd "$workdir" cd "$workdir"
if [ -n "$CMakeGenerator" ]; then if [ -n "$CMakeGenerator" ]; then
cmake -G "$CMakeGenerator" $CMakeCacheEntries "$sourcedir" "$CMakeCommand" -G "$CMakeGenerator" $CMakeCacheEntries "$sourcedir"
else else
cmake $CMakeCacheEntries "$sourcedir" "$CMakeCommand" $CMakeCacheEntries "$sourcedir"
fi fi
printf "#!/bin/sh\n\n" > config.status printf "#!/bin/sh\n\n" > config.status
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2020 Dominik Charousset *
* *
* 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/test/dsl.hpp"
CAF_BEGIN_TYPE_ID_BLOCK(bb_test, caf::first_custom_type_id)
CAF_ADD_TYPE_ID(bb_test, (caf::stream<int>) )
CAF_ADD_TYPE_ID(bb_test, (std::vector<int>) )
CAF_END_TYPE_ID_BLOCK(bb_test)
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "caf/bb/container_source.hpp" #include "caf/bb/container_source.hpp"
#include "caf/bb/test/bb_test_type_ids.hpp"
#include "caf/test/dsl.hpp" #include "caf/test/dsl.hpp"
#include <vector> #include <vector>
...@@ -74,7 +75,7 @@ TESTEE(container_monitor) { ...@@ -74,7 +75,7 @@ TESTEE(container_monitor) {
struct config : actor_system_config { struct config : actor_system_config {
config() { config() {
add_message_type<container_type::value_type>("value_type"); // nop
} }
}; };
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
#include "caf/bb/stream_reader.hpp" #include "caf/bb/stream_reader.hpp"
#include "caf/policy/tokenized_integer_reader.hpp" #include "caf/policy/tokenized_integer_reader.hpp"
#include "caf/bb/test/bb_test_type_ids.hpp"
#include "caf/test/dsl.hpp" #include "caf/test/dsl.hpp"
#include <memory> #include <memory>
#include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -125,8 +125,7 @@ public: ...@@ -125,8 +125,7 @@ public:
// nop // nop
} }
static expected<buffer_type> serialize(actor_system& sys, static expected<buffer_type> serialize(actor_system& sys, const message& x);
const type_erased_tuple& x);
// -- utility functions ------------------------------------------------------ // -- utility functions ------------------------------------------------------
......
...@@ -48,8 +48,7 @@ public: ...@@ -48,8 +48,7 @@ public:
using maybe_buffer = expected<std::vector<byte>>; using maybe_buffer = expected<std::vector<byte>>;
/// A function type for serializing message payloads. /// A function type for serializing message payloads.
using serialize_fun_type = maybe_buffer (*)(actor_system&, using serialize_fun_type = maybe_buffer (*)(actor_system&, const message&);
const type_erased_tuple&);
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/send.hpp" #include "caf/send.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
#include "caf/type_erased_tuple.hpp"
namespace caf::net::basp { namespace caf::net::basp {
...@@ -120,10 +119,10 @@ void application::local_actor_down(packet_writer& writer, actor_id id, ...@@ -120,10 +119,10 @@ void application::local_actor_down(packet_writer& writer, actor_id id,
} }
expected<std::vector<byte>> application::serialize(actor_system& sys, expected<std::vector<byte>> application::serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
std::vector<byte> result; std::vector<byte> result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "caf/detail/net_syscall.hpp" #include "caf/detail/net_syscall.hpp"
#include "caf/detail/socket_sys_includes.hpp" #include "caf/detail/socket_sys_includes.hpp"
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/make_message.hpp"
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/net/socket.hpp" #include "caf/net/socket.hpp"
#include "caf/none.hpp" #include "caf/none.hpp"
......
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/logger.hpp" #include "caf/logger.hpp"
#include "caf/make_counted.hpp"
#include "caf/net/operation.hpp" #include "caf/net/operation.hpp"
#include "caf/net/pollset_updater.hpp" #include "caf/net/pollset_updater.hpp"
#include "caf/net/socket_manager.hpp" #include "caf/net/socket_manager.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/span.hpp"
#include "caf/variant.hpp" #include "caf/variant.hpp"
#ifndef CAF_WINDOWS #ifndef CAF_WINDOWS
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include "caf/detail/socket_sys_aliases.hpp" #include "caf/detail/socket_sys_aliases.hpp"
#include "caf/detail/socket_sys_includes.hpp" #include "caf/detail/socket_sys_includes.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/make_message.hpp"
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/net/stream_socket.hpp" #include "caf/net/stream_socket.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/span.hpp"
#include "caf/variant.hpp" #include "caf/variant.hpp"
namespace caf::net { namespace caf::net {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "caf/ip_endpoint.hpp" #include "caf/ip_endpoint.hpp"
#include "caf/logger.hpp" #include "caf/logger.hpp"
#include "caf/net/socket_guard.hpp" #include "caf/net/socket_guard.hpp"
#include "caf/span.hpp"
namespace caf::net { namespace caf::net {
......
...@@ -166,11 +166,10 @@ public: ...@@ -166,11 +166,10 @@ public:
CAF_FAIL("handle_error called: " << to_string(sec)); CAF_FAIL("handle_error called: " << to_string(sec));
} }
static expected<buffer_type> serialize(actor_system& sys, static expected<buffer_type> serialize(actor_system& sys, const message& x) {
const type_erased_tuple& x) {
buffer_type result; buffer_type result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
......
...@@ -61,10 +61,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture { ...@@ -61,10 +61,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture {
class dummy_application { class dummy_application {
public: public:
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
std::vector<byte> result; std::vector<byte> result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
using application_type = dummy_application; using application_type = dummy_application;
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
return dummy_application::serialize(sys, x); return dummy_application::serialize(sys, x);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "caf/net/make_endpoint_manager.hpp" #include "caf/net/make_endpoint_manager.hpp"
#include "caf/net/multiplexer.hpp" #include "caf/net/multiplexer.hpp"
#include "caf/net/stream_socket.hpp" #include "caf/net/stream_socket.hpp"
#include "caf/node_id.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
using namespace caf; using namespace caf;
...@@ -62,10 +63,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture { ...@@ -62,10 +63,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture {
class dummy_application { class dummy_application {
public: public:
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
std::vector<byte> result; std::vector<byte> result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
...@@ -124,7 +125,7 @@ public: ...@@ -124,7 +125,7 @@ public:
template <class Manager> template <class Manager>
void resolve(Manager& mgr, const uri& locator, const actor& listener) { void resolve(Manager& mgr, const uri& locator, const actor& listener) {
actor_id aid = 42; actor_id aid = 42;
auto hid = "0011223344556677889900112233445566778899"; auto hid = string_view("0011223344556677889900112233445566778899");
auto nid = unbox(make_node_id(42, hid)); auto nid = unbox(make_node_id(42, hid));
actor_config cfg; actor_config cfg;
auto p = make_actor<actor_proxy_impl, strong_actor_ptr>(aid, nid, auto p = make_actor<actor_proxy_impl, strong_actor_ptr>(aid, nid,
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
template <class Parent> template <class Parent>
void resolve(Parent& parent, string_view path, const actor& listener) { void resolve(Parent& parent, string_view path, const actor& listener) {
actor_id aid = 42; actor_id aid = 42;
auto hid = "0011223344556677889900112233445566778899"; auto hid = string_view("0011223344556677889900112233445566778899");
auto nid = unbox(make_node_id(42, hid)); auto nid = unbox(make_node_id(42, hid));
actor_config cfg; actor_config cfg;
endpoint_manager_ptr ptr{&parent.manager()}; endpoint_manager_ptr ptr{&parent.manager()};
...@@ -137,11 +137,10 @@ public: ...@@ -137,11 +137,10 @@ public:
// nop // nop
} }
static expected<buffer_type> serialize(actor_system& sys, static expected<buffer_type> serialize(actor_system& sys, const message& x) {
const type_erased_tuple& x) {
buffer_type result; buffer_type result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
......
...@@ -113,10 +113,10 @@ public: ...@@ -113,10 +113,10 @@ public:
} }
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
std::vector<byte> result; std::vector<byte> result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
template <class Parent> template <class Parent>
void resolve(Parent& parent, string_view path, actor listener) { void resolve(Parent& parent, string_view path, actor listener) {
actor_id aid = 42; actor_id aid = 42;
auto hid = "0011223344556677889900112233445566778899"; auto hid = string_view("0011223344556677889900112233445566778899");
auto nid = unbox(make_node_id(aid, hid)); auto nid = unbox(make_node_id(aid, hid));
actor_config cfg; actor_config cfg;
auto sys = &parent.system(); auto sys = &parent.system();
......
...@@ -103,10 +103,10 @@ public: ...@@ -103,10 +103,10 @@ public:
} }
static expected<std::vector<byte>> serialize(actor_system& sys, static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) { const message& x) {
std::vector<byte> result; std::vector<byte> result;
binary_serializer sink{sys, result}; binary_serializer sink{sys, result};
if (auto err = message::save(sink, x)) if (auto err = x.save(sink))
return err.value(); return err.value();
return result; return result;
} }
......
...@@ -92,8 +92,7 @@ public: ...@@ -92,8 +92,7 @@ public:
rec_buf_->push_back(static_cast<byte>(id_)); rec_buf_->push_back(static_cast<byte>(id_));
} }
static expected<buffer_type> serialize(actor_system&, static expected<buffer_type> serialize(actor_system&, const message&) {
const type_erased_tuple&) {
return buffer_type{}; return buffer_type{};
} }
......
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