Commit 5813911c authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'unstable'

parents e8f7d3f1 daf7521c
html/
.DS_Store
*.o
*.dylib
test
*.png
*.dat
*.ii
*.s
*.tmp
*.la
*.lo
*.dump
*.beam *.beam
*.class *.class
benchmarks/mailbox_performance *.dat
benchmarks/actor_creation *.dump
benchmarks/mixed_case *.png
benchmarks/matching *.tmp
theron_mailbox_performance .DS_Store
.libs/
.deps/
libcppa.pc
Makefile.in
aclocal.m4
autom4te.cache/
gen_server/parallel_send
gen_server/sequential_send
gen_server/test.dSYM/
depcomp
install-sh
libtool
ltmain.sh
missing
unit_testing/Makefile.in
unit_testing/unit_tests
unit_testing/.deps/
config.*
configure
INSTALL
m4/libtool.m4
m4/lt*.m4
a.out*
queue_test
cppa.creator.user
8threads
4threads
libcppa.Makefile
variadic_templates_test
variadic_templates_test.dSYM/
Makefile
unit_testing/Makefile
libcppa.so*
blob/cppatest
callgrind.out* callgrind.out*
examples/announce_example_1 cppa.creator.user
examples/announce_example_2 html/
examples/announce_example_3 libcppa.pc
examples/announce_example_4 bin/*
examples/announce_example_5 build/*
examples/hello_world_example lib/*
examples/math_actor_example
examples/dining_philosophers
examples/dancing_kirby
cmake_minimum_required(VERSION 2.4)
project(cppa CXX)
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wextra -Wall -pedantic")
set(LIBCPPA_SRC
src/abstract_tuple.cpp
src/actor.cpp
src/actor_count.cpp
src/actor_proxy.cpp
src/actor_proxy_cache.cpp
src/actor_registry.cpp
src/addressed_message.cpp
src/any_tuple.cpp
src/atom.cpp
src/attachable.cpp
src/behavior_stack.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/channel.cpp
src/thread_mapped_actor.cpp
src/demangle.cpp
src/deserializer.cpp
src/duration.cpp
src/empty_tuple.cpp
src/event_based_actor.cpp
src/exception.cpp
src/factory.cpp
src/fiber.cpp
src/group.cpp
src/group_manager.cpp
src/local_actor.cpp
src/mailman.cpp
src/native_socket.cpp
src/network_manager.cpp
src/object.cpp
src/object_array.cpp
src/partial_function.cpp
src/pattern.cpp
src/post_office.cpp
src/primitive_variant.cpp
src/process_information.cpp
src/receive.cpp
src/ripemd_160.cpp
src/scheduled_actor.cpp
src/scheduled_actor_dummy.cpp
src/scheduler.cpp
src/self.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/singleton_manager.cpp
src/string_serialization.cpp
src/thread_pool_scheduler.cpp
src/to_uniform_name.cpp
src/unicast_network.cpp
src/uniform_type_info.cpp
src/yield_interface.cpp
src/context_switching_actor.cpp
)
set(boost_context third_party/boost_context/)
# add third_party boost_context sources
if(APPLE)
set_property(SOURCE
${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S
PROPERTY LANGUAGE CXX)
set(LIBCPPA_SRC
${LIBCPPA_SRC}
${boost_context}/src/stack_utils_posix.cpp
${boost_context}/src/stack_allocator_posix.cpp
${boost_context}/src/fcontext.cpp
${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S
)
elseif(UNIX)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_property(SOURCE
${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S
PROPERTY LANGUAGE CXX)
set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S)
else()
set_property(SOURCE
${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S
PROPERTY LANGUAGE CXX)
set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S)
endif()
set(LIBCPPA_SRC
${LIBCPPA_SRC}
${fcontext_asm}
${boost_context}/src/stack_utils_posix.cpp
${boost_context}/src/stack_allocator_posix.cpp
${boost_context}/src/fcontext.cpp
)
endif()
find_package(Boost COMPONENTS thread REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include)
add_library(libcppa SHARED ${LIBCPPA_SRC})
target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})
set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 2)
set(LIBCPPA_VERSION_PATCH 0)
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
set_target_properties(libcppa PROPERTIES SOVERSION ${LIBRARY_SOVERSION} VERSION ${LIBRARY_VERSION} OUTPUT_NAME cppa)
install(TARGETS libcppa LIBRARY DESTINATION lib)
# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa
FILES_MATCHING PATTERN "*.hpp")
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
if (LIBRARY_OUTPUT_PATH)
set (CPPA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
set (CPPA_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH})
else()
set (CPPA_LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set (CPPA_LIBRARY_PATH ${CPPA_LIBRARY_OUTPUT_PATH})
set (LIBRARY_OUTPUT_PATH ${CPPA_LIBRARY_OUTPUT_PATH} CACHE PATH "Single directory for all libraries")
endif()
# setting path to cppa headers and libcppa
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
if (APPLE)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
elseif (UNIX)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.so)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
if (EXECUTABLE_OUTPUT_PATH)
else ()
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single directory for all executables")
endif ()
add_subdirectory(unit_testing)
add_subdirectory(examples)
add_subdirectory(benchmarks)
#add_subdirectory(benchmarks)
#add_dependencies(unit_tests libcppa)
#add_dependencies(benchmarks libcppa)
add_dependencies(announce_example_1 libcppa)
add_dependencies(announce_example_2 libcppa)
add_dependencies(announce_example_3 libcppa)
add_dependencies(announce_example_4 libcppa)
add_dependencies(announce_example_5 libcppa)
add_dependencies(dancing_kirby libcppa)
add_dependencies(dining_philosophers libcppa)
add_dependencies(hello_world_example libcppa)
add_dependencies(math_actor_example libcppa)
add_dependencies(unit_tests libcppa)
add_dependencies(actor_creation libcppa)
add_dependencies(mailbox_performance libcppa)
add_dependencies(mixed_case libcppa)
add_dependencies(distributed libcppa)
add_dependencies(matching libcppa)
This diff is collapsed.
Version 0.2
2012-06-29
- Removed become_void() [use quit() instead]
- Renamed "future_send()" to "delayed_send()"
- Removed "stacked_actor"; moved functionality to "event_based_actor"
- Renamed "fsm_actor" to "sb_actor"
- Refactored "spawn": spawn(new T(...)) => spawn<T>(...)
- Implemented become()/unbecome() for context-switching & thread-mapped actors
- Moved become()/unbecome() to local_actor
- Ported libcppa from <ucontext.h> to Boost.Context library
ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES = libcppa.la
libcppa_la_SOURCES = \
src/abstract_event_based_actor.cpp \
src/abstract_scheduled_actor.cpp \
src/abstract_tuple.cpp \
src/actor.cpp \
src/actor_count.cpp \
src/actor_proxy.cpp \
src/actor_proxy_cache.cpp \
src/actor_registry.cpp \
src/addressed_message.cpp \
src/any_tuple.cpp \
src/atom.cpp \
src/attachable.cpp \
src/binary_deserializer.cpp \
src/binary_serializer.cpp \
src/channel.cpp \
src/converted_thread_context.cpp \
src/cppa.cpp \
src/demangle.cpp \
src/deserializer.cpp \
src/duration.cpp \
src/empty_tuple.cpp \
src/event_based_actor.cpp \
src/exception.cpp \
src/fiber.cpp \
src/group.cpp \
src/group_manager.cpp \
src/invokable.cpp \
src/local_actor.cpp \
src/mailman.cpp \
src/mock_scheduler.cpp \
src/native_socket.cpp \
src/network_manager.cpp \
src/object.cpp \
src/object_array.cpp \
src/partial_function.cpp \
src/pattern.cpp \
src/post_office.cpp \
src/post_office_msg.cpp \
src/primitive_variant.cpp \
src/process_information.cpp \
src/receive.cpp \
src/ripemd_160.cpp \
src/scheduled_actor.cpp \
src/scheduler.cpp \
src/self.cpp \
src/serializer.cpp \
src/shared_spinlock.cpp \
src/singleton_manager.cpp \
src/stacked_event_based_actor.cpp \
src/string_serialization.cpp \
src/thread_pool_scheduler.cpp \
src/to_uniform_name.cpp \
src/unicast_network.cpp \
src/uniform_type_info.cpp \
src/yield_interface.cpp \
src/yielding_actor.cpp
if VERSIONED_INCLUDE_DIR
library_includedir = $(includedir)/cppa/$(PACKAGE_VERSION)/
else
library_includedir = $(includedir)/
endif
nobase_library_include_HEADERS = \
cppa/abstract_actor.hpp \
cppa/abstract_event_based_actor.hpp \
cppa/actor.hpp \
cppa/actor_proxy.hpp \
cppa/announce.hpp \
cppa/any_tuple.hpp \
cppa/anything.hpp \
cppa/atom.hpp \
cppa/attachable.hpp \
cppa/behavior.hpp \
cppa/binary_deserializer.hpp \
cppa/binary_serializer.hpp \
cppa/channel.hpp \
cppa/config.hpp \
cppa/cow_ptr.hpp \
cppa/cow_tuple.hpp \
cppa/cppa.hpp \
cppa/deserializer.hpp \
cppa/detail/abstract_scheduled_actor.hpp \
cppa/detail/abstract_tuple.hpp \
cppa/detail/actor_count.hpp \
cppa/detail/actor_proxy_cache.hpp \
cppa/detail/actor_registry.hpp \
cppa/detail/addressed_message.hpp \
cppa/detail/atom_val.hpp \
cppa/detail/boxed.hpp \
cppa/detail/buffer.hpp \
cppa/detail/channel.hpp \
cppa/detail/container_tuple_view.hpp \
cppa/detail/converted_thread_context.hpp \
cppa/detail/decorated_tuple.hpp \
cppa/detail/default_uniform_type_info_impl.hpp \
cppa/detail/demangle.hpp \
cppa/detail/disablable_delete.hpp \
cppa/detail/empty_tuple.hpp \
cppa/detail/get_behavior.hpp \
cppa/detail/group_manager.hpp \
cppa/detail/implicit_conversions.hpp \
cppa/detail/invokable.hpp \
cppa/detail/list_member.hpp \
cppa/detail/mailman.hpp \
cppa/detail/map_member.hpp \
cppa/detail/matches.hpp \
cppa/detail/mock_scheduler.hpp \
cppa/detail/native_socket.hpp \
cppa/detail/network_manager.hpp \
cppa/detail/object_array.hpp \
cppa/detail/object_impl.hpp \
cppa/detail/pair_member.hpp \
cppa/detail/post_office.hpp \
cppa/detail/post_office_msg.hpp \
cppa/detail/primitive_member.hpp \
cppa/detail/projection.hpp \
cppa/detail/pseudo_tuple.hpp \
cppa/detail/ptype_to_type.hpp \
cppa/detail/receive_loop_helper.hpp \
cppa/detail/ref_counted_impl.hpp \
cppa/detail/serialize_tuple.hpp \
cppa/detail/singleton_manager.hpp \
cppa/detail/swap_bytes.hpp \
cppa/detail/tdata.hpp \
cppa/detail/thread.hpp \
cppa/detail/thread_pool_scheduler.hpp \
cppa/detail/to_uniform_name.hpp \
cppa/detail/tuple_cast_impl.hpp \
cppa/detail/tuple_iterator.hpp \
cppa/detail/tuple_vals.hpp \
cppa/detail/tuple_view.hpp \
cppa/detail/type_to_ptype.hpp \
cppa/detail/types_array.hpp \
cppa/detail/unboxed.hpp \
cppa/detail/uniform_type_info_map.hpp \
cppa/detail/value_guard.hpp \
cppa/detail/yield_interface.hpp \
cppa/detail/yielding_actor.hpp \
cppa/either.hpp \
cppa/event_based_actor.hpp \
cppa/event_based_actor_base.hpp \
cppa/exception.hpp \
cppa/exit_reason.hpp \
cppa/from_string.hpp \
cppa/fsm_actor.hpp \
cppa/get.hpp \
cppa/group.hpp \
cppa/guard_expr.hpp \
cppa/intrusive/forward_iterator.hpp \
cppa/intrusive/single_reader_queue.hpp \
cppa/intrusive/singly_linked_list.hpp \
cppa/intrusive_ptr.hpp \
cppa/local_actor.hpp \
cppa/match.hpp \
cppa/match_expr.hpp \
cppa/object.hpp \
cppa/on.hpp \
cppa/option.hpp \
cppa/partial_function.hpp \
cppa/pattern.hpp \
cppa/primitive_type.hpp \
cppa/primitive_variant.hpp \
cppa/process_information.hpp \
cppa/receive.hpp \
cppa/ref_counted.hpp \
cppa/scheduled_actor.hpp \
cppa/scheduler.hpp \
cppa/scheduling_hint.hpp \
cppa/self.hpp \
cppa/serializer.hpp \
cppa/stacked_event_based_actor.hpp \
cppa/to_string.hpp \
cppa/tpartial_function.hpp \
cppa/tuple_cast.hpp \
cppa/type_value_pair.hpp \
cppa/uniform_type_info.hpp \
cppa/util/abstract_uniform_type_info.hpp \
cppa/util/apply_args.hpp \
cppa/util/apply_tuple.hpp \
cppa/util/arg_match_t.hpp \
cppa/util/at.hpp \
cppa/util/callable_trait.hpp \
cppa/util/comparable.hpp \
cppa/util/compare_tuples.hpp \
cppa/util/conjunction.hpp \
cppa/util/deduce_ref_type.hpp \
cppa/util/disjunction.hpp \
cppa/util/duration.hpp \
cppa/util/element_at.hpp \
cppa/util/fiber.hpp \
cppa/util/fixed_vector.hpp \
cppa/util/if_else.hpp \
cppa/util/is_array_of.hpp \
cppa/util/is_builtin.hpp \
cppa/util/is_comparable.hpp \
cppa/util/is_forward_iterator.hpp \
cppa/util/is_iterable.hpp \
cppa/util/is_legal_tuple_type.hpp \
cppa/util/is_manipulator.hpp \
cppa/util/is_mutable_ref.hpp \
cppa/util/is_primitive.hpp \
cppa/util/left_or_right.hpp \
cppa/util/producer_consumer_list.hpp \
cppa/util/projection.hpp \
cppa/util/pt_dispatch.hpp \
cppa/util/pt_token.hpp \
cppa/util/purge_refs.hpp \
cppa/util/replace_type.hpp \
cppa/util/ripemd_160.hpp \
cppa/util/rm_option.hpp \
cppa/util/rm_ref.hpp \
cppa/util/shared_lock_guard.hpp \
cppa/util/shared_spinlock.hpp \
cppa/util/static_foreach.hpp \
cppa/util/tbind.hpp \
cppa/util/type_list.hpp \
cppa/util/type_pair.hpp \
cppa/util/upgrade_lock_guard.hpp \
cppa/util/void_type.hpp \
cppa/util/wrapped.hpp
libcppa_la_CXXFLAGS = --std=c++0x -pedantic -Wall -Wextra
libcppa_la_LDFLAGS = -release $(PACKAGE_VERSION) $(BOOST_CPPFLAGS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcppa.pc
SUBDIRS = . unit_testing examples benchmarks
Blog: http://libcppa.blogspot.com
This project is in an early / experimental stage.
It makes use of variadic templates, unrestricted unions,
type inference and other C++11 features.
Thus, GCC in version >= 4.6 is required to compile libcppa.
You'll also need automake and the boost thread library.
Building libcppa:
* autoreconf -i
* ./configure
* make
libcppa
=======
libcppa is an LGPL C++11 actor model implementation featuring lightweight & fast
actor implementations, pattern matching for messages,
network transparent messaging, and more.
On the Web
----------
* __Blog__: http://libcppa.blogspot.com
* __Manual__: http://neverlord.github.com/libcppa/manual/
* __Documentation__: http://neverlord.github.com/libcppa/
* __Project Homepage__: http://www.realmv6.org/libcppa.html
Get the Sources
---------------
* git clone git://github.com/Neverlord/libcppa.git
* cd libcppa
First Steps
-----------
* mkdir build
* cd build
* cmake ..
* make
It is recommended to run the unit tests as well.
* ./bin/unit_tests
Please submit a bug report that includes (a) your compiler version, (b) your OS,
and (c) the output of the unit tests if an error occurs.
Dependencies
------------
* CMake
* The Boost Library
Supported Compilers
-------------------
* GCC >= 4.7
* Clang >= 3.2
Supported Operating Systems
---------------------------
* Linux
* Mac OS X
...@@ -104,14 +104,12 @@ object ActorCreation { ...@@ -104,14 +104,12 @@ object ActorCreation {
if (args(0) == "threaded") { if (args(0) == "threaded") {
val newMax = (1 << n) + 100 val newMax = (1 << n) + 100
System.setProperty("actors.maxPoolSize", newMax.toString) System.setProperty("actors.maxPoolSize", newMax.toString)
//actor {
(new ThreadedTestee(self)).start ! Spread(n) (new ThreadedTestee(self)).start ! Spread(n)
receive { receive {
case Result(v) => case Result(v) =>
if (v != (1 << n)) if (v != (1 << n))
Console.println("ERROR: expected " + (1 << n) + ", received " + v) Console.println("ERROR: expected " + (1 << n) + ", received " + v)
} }
//}
} }
else if (args(0) == "threadless") { else if (args(0) == "threadless") {
actor { actor {
......
cmake_minimum_required(VERSION 2.6)
project(cppa_benchmarks CXX)
# Set up environment paths to cmake modules and libcppa
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(actor_creation actor_creation.cpp)
add_executable(mailbox_performance mailbox_performance.cpp)
add_executable(mixed_case mixed_case.cpp)
add_executable(distributed distributed.cpp)
add_executable(matching matching.cpp)
# search for libs
if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED)
endif (NOT cppa_LIBRARY)
find_package(Boost COMPONENTS thread REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
set(benchmark_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
target_link_libraries(actor_creation ${benchmark_LIBS})
target_link_libraries(mailbox_performance ${benchmark_LIBS})
target_link_libraries(mixed_case ${benchmark_LIBS})
target_link_libraries(distributed ${benchmark_LIBS})
target_link_libraries(matching ${benchmark_LIBS})
This diff is collapsed.
# - Try to find libcppa
# Once done this will define
#
# CPPA_FOUND - system has libcppa
# CPPA_INCLUDE - libcppa include dir
# CPPA_LIBRARY - link againgst libcppa
#
if (CPPA_LIBRARY AND CPPA_INCLUDE)
set(CPPA_FOUND TRUE)
else (CPPA_LIBRARY AND CPPA_INCLUDE)
find_path(CPPA_INCLUDE
NAMES
cppa/cppa.hpp
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
${CPPA_INCLUDE_PATH}
${CPPA_LIBRARY_PATH}
${CMAKE_INCLUDE_PATH}
${CMAKE_INSTALL_PREFIX}/include
)
if (CPPA_INCLUDE)
message (STATUS "Header files found ...")
else (CPPA_INCLUDE)
message (SEND_ERROR "Header files NOT found. Provide absolute path with -DCPPA_INCLUDE_PATH=<path-to-header>.")
endif (CPPA_INCLUDE)
find_library(CPPA_LIBRARY
NAMES
libcppa
cppa
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${CPPA_INCLUDE_PATH}
${CPPA_INCLUDE_PATH}/.libs
${CPPA_LIBRARY_PATH}
${CPPA_LIBRARY_PATH}/.libs
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
${LIBRARY_OUTPUT_PATH}
)
if (CPPA_LIBRARY)
message (STATUS "Library found ...")
else (CPPA_LIBRARY)
message (SEND_ERROR "Library NOT found. Provide absolute path with -DCPPA_LIBRARY_PATH=<path-to-library>.")
endif (CPPA_LIBRARY)
if (CPPA_INCLUDE AND CPPA_LIBRARY)
set(CPPA_FOUND TRUE)
set(CPPA_INCLUDE ${CPPA_INCLUDE})
set(CPPA_LIBRARY ${CPPA_LIBRARY})
else (CPPA_INCLUDE AND CPPA_LIBRARY)
message (FATAL_ERROR "CPPA LIBRARY AND/OR HEADER NOT FOUND!")
endif (CPPA_INCLUDE AND CPPA_LIBRARY)
endif (CPPA_LIBRARY AND CPPA_INCLUDE)
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I ../m4
AM_CXXFLAGS = -I../ --std=c++0x -pedantic -Wall -Wextra
noinst_PROGRAMS = actor_creation mailbox_performance mixed_case matching
actor_creation_SOURCES = actor_creation.cpp
mailbox_performance_SOURCES = mailbox_performance.cpp
mixed_case_SOURCES = mixed_case.cpp
matching_SOURCES = matching.cpp
EXAMPLES_LIBS = -L../.libs/ -lcppa $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
actor_creation_LDADD = $(EXAMPLES_LIBS)
mailbox_performance_LDADD = $(EXAMPLES_LIBS)
mixed_case_LDADD = $(EXAMPLES_LIBS)
matching_LDADD = $(EXAMPLES_LIBS)
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "utility.hpp" #include "utility.hpp"
#include "cppa/cppa.hpp" #include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp" #include "cppa/sb_actor.hpp"
using std::cout; using std::cout;
using std::cerr; using std::cerr;
...@@ -44,34 +44,25 @@ using std::uint32_t; ...@@ -44,34 +44,25 @@ using std::uint32_t;
using namespace cppa; using namespace cppa;
struct testee : fsm_actor<testee> struct testee : sb_actor<testee> {
{
actor_ptr parent; actor_ptr parent;
behavior init_state; behavior init_state;
testee(const actor_ptr& pptr) : parent(pptr) testee(const actor_ptr& pptr) : parent(pptr) {
{ init_state = (
init_state = on(atom("spread"), 0) >> [=]() {
(
on(atom("spread"), 0) >> [=]()
{
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
become_void(); quit();
}, },
on<atom("spread"), int>() >> [=](int x) on<atom("spread"), int>() >> [=](int x) {
{
any_tuple msg = make_cow_tuple(atom("spread"), x - 1); any_tuple msg = make_cow_tuple(atom("spread"), x - 1);
spawn(new testee(this)) << msg; spawn<testee>(this) << msg;
spawn(new testee(this)) << msg; spawn<testee>(this) << msg;
become become (
( on<atom("result"), uint32_t>() >> [=](uint32_t r1) {
on<atom("result"), uint32_t>() >> [=](uint32_t r1) become (
{ on<atom("result"), uint32_t>() >> [=](uint32_t r2) {
become
(
on<atom("result"), uint32_t>() >> [=](uint32_t r2)
{
send(parent, atom("result"), r1 + r2); send(parent, atom("result"), r1 + r2);
become_void(); quit();
} }
); );
} }
...@@ -81,27 +72,19 @@ struct testee : fsm_actor<testee> ...@@ -81,27 +72,19 @@ struct testee : fsm_actor<testee>
} }
}; };
void stacked_testee(actor_ptr parent) void stacked_testee(actor_ptr parent) {
{ receive (
receive on(atom("spread"), 0) >> [&]() {
(
on(atom("spread"), 0) >> [&]()
{
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
}, },
on<atom("spread"), int>() >> [&](int x) on<atom("spread"), int>() >> [&](int x) {
{
any_tuple msg = make_cow_tuple(atom("spread"), x-1); any_tuple msg = make_cow_tuple(atom("spread"), x-1);
spawn(stacked_testee, self) << msg; spawn(stacked_testee, self) << msg;
spawn(stacked_testee, self) << msg; spawn(stacked_testee, self) << msg;
receive receive (
( on<atom("result"), uint32_t>() >> [&](uint32_t v1) {
on<atom("result"), uint32_t>() >> [&](uint32_t v1) receive (
{ on<atom("result"),uint32_t>() >> [&](uint32_t v2) {
receive
(
on<atom("result"),uint32_t>() >> [&](uint32_t v2)
{
send(parent, atom("result"), v1 + v2); send(parent, atom("result"), v1 + v2);
} }
); );
...@@ -111,45 +94,38 @@ void stacked_testee(actor_ptr parent) ...@@ -111,45 +94,38 @@ void stacked_testee(actor_ptr parent)
); );
} }
void usage() void usage() {
{
cout << "usage: actor_creation (stacked|event-based) POW" << endl cout << "usage: actor_creation (stacked|event-based) POW" << endl
<< " creates 2^POW actors" << endl << " creates 2^POW actors" << endl
<< endl; << endl;
} }
int main(int argc, char** argv) int main(int argc, char** argv) {
{ if (argc == 3) {
if (argc == 3)
{
int num = rd<int>(argv[2]); int num = rd<int>(argv[2]);
if (strcmp(argv[1], "stacked") == 0) if (strcmp(argv[1], "stacked") == 0) {
{
send(spawn(stacked_testee, self), atom("spread"), num); send(spawn(stacked_testee, self), atom("spread"), num);
} }
else if (strcmp(argv[1], "event-based") == 0) else if (strcmp(argv[1], "event-based") == 0) {
{ send(spawn<testee>(self), atom("spread"), num);
send(spawn(new testee(self)), atom("spread"), num);
} }
else else {
{
usage(); usage();
return 1; return 1;
} }
receive receive (
( on<atom("result"),uint32_t>() >> [=](uint32_t value) {
on<atom("result"),uint32_t>() >> [=](uint32_t value)
{
//cout << "value = " << value << endl //cout << "value = " << value << endl
// << "expected => 2^" << num << " = " // << "expected => 2^" << num << " = "
// << (1 << num) << endl; // << (1 << num) << endl;
assert(value == (((uint32_t) 1) << num)); if (value != (((uint32_t) 1) << num)) {
cerr << "ERROR: received wrong result!\n";
}
} }
); );
await_all_others_done(); await_all_others_done();
} }
else else {
{
usage(); usage();
return 1; return 1;
} }
......
benchmark {
akka {
loglevel = ERROR
actor.provider = "akka.remote.RemoteActorRefProvider"
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
untrusted-mode = on
# remote-daemon-ack-timeout = 300s
# netty {
# connection-timeout = 1800s
# }
}
}
}
pongServer {
akka {
loglevel = ERROR
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
untrusted-mode = on
# remote-daemon-ack-timeout = 300s
netty {
# backoff-timeout = 0ms
connection-timeout = 1800s
# read-timeout = 1800s
# write-timeout = 10s
all-timeout = 1800s
#hostname = "mobi10"
port = 2244
}
}
}
}
This diff is collapsed.
-module(distributed).
-export([start/1, ping_loop/2]).
ping_loop(Parent, Pong) ->
receive
{pong, 0} -> Parent ! done;
{pong, X} ->
Pong ! {ping, self(), X - 1},
ping_loop(Parent, Pong);
{kickoff, X} ->
Pong ! {ping, self(), X},
ping_loop(Parent, Pong);
_ -> ping_loop(Parent, Pong)
end.
server_loop(Pongs) ->
receive
{ping, Pid, X} ->
Pid ! {pong, X},
server_loop(Pongs);
{add_pong, Pid, Node} ->
case lists:any(fun({N, _}) -> N == Node end, Pongs) of
true ->
Pid ! {ok, cached},
server_loop(Pongs);
false ->
case rpc:call(Node, erlang, whereis, [pong]) of
{badrpc, Reason} ->
Pid ! {error, Reason},
server_loop(Pongs);
undefined ->
Pid ! {error, 'pong is undefined'},
server_loop(Pongs);
Pong ->
Pid ! {ok, added},
server_loop(Pongs ++ [{Node, Pong}])
end
end;
{purge} -> server_loop([]);
{get_pongs, Pid} ->
Pid ! Pongs,
server_loop(Pongs);
{kickoff, Pid, NumPings} ->
lists:foreach(fun({_, P}) -> spawn(distributed, ping_loop, [Pid, P]) ! {kickoff, NumPings} end, Pongs),
server_loop(Pongs);
_ -> server_loop(Pongs)
end.
server_mode() ->
register(pong, self()),
server_loop([]).
add_pong_fun(_, _, []) -> true;
add_pong_fun(Pong, Node, [Node|T]) -> add_pong_fun(Pong, Node, T);
add_pong_fun(Pong, Node, [H|T]) ->
Pong ! {add_pong, self(), H},
receive
{ok, _} -> add_pong_fun(Pong, Node, T);
{error, Reason} -> error(Reason)
after 10000 -> error(timeout)
end.
client_mode_receive_done_msgs(0) -> true;
client_mode_receive_done_msgs(Left) ->
receive done -> client_mode_receive_done_msgs(Left - 1) end.
% receive a {done} message for each node
client_mode([], [], [], _) -> error("no node, no fun");
client_mode([], [], Nodes, _) ->
client_mode_receive_done_msgs(length(Nodes) * (length(Nodes) - 1));
% send kickoff messages
client_mode([Pong|Pongs], [], Nodes, NumPings) ->
Pong ! {kickoff, self(), NumPings},
client_mode(Pongs, [], Nodes, NumPings);
client_mode(Pongs, [H|T], Nodes, NumPings) ->
case rpc:call(H, erlang, whereis, [pong]) of
{badrpc, Reason} ->
io:format("cannot connect to ~s~n", [atom_to_list(H)]),
error(Reason);
undefined ->
io:format("no 'pong' defined on node ~s~n", [atom_to_list(H)]);
P ->
add_pong_fun(P, H, Nodes),
client_mode(Pongs ++ [P], T, Nodes, NumPings)
end.
run(_, undefined, []) -> error("NumPings is undefined");
run(Hosts, _, []) when length(Hosts) < 2 -> error("less than two nodes specified");
run(Hosts, NumPings, []) -> client_mode([], Hosts, Hosts, NumPings);
run(Hosts, NumPings, [H|T]) ->
Arg = atom_to_list(H),
case lists:prefix("num_pings=", Arg) of
true when NumPings /= undefined -> error("NumPings already set");
true -> run(Hosts, list_to_integer(lists:sublist(Arg, 11, length(Arg))), T);
false -> run(Hosts ++ [H], NumPings, T)
end.
start(X) ->
case X of
['mode=server'|[]] -> server_mode();
['mode=server'|_] -> io:format("too much arguments~n", []);
['mode=benchmark'|T] -> run([], undefined, T);
_ -> io:format("invalid arguments~n", [])
end.
#!/bin/bash #!/bin/bash
echo "erl -noshell -noinput +P 20000000 -s $@ -s init stop" | ./exec.sh echo "erl -noshell -noinput +P 20000000 -setcookie abc123 -sname benchmark -s $@ -s init stop" | ./exec.sh
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
\******************************************************************************/ \******************************************************************************/
#include <thread>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
...@@ -35,8 +36,7 @@ ...@@ -35,8 +36,7 @@
#include "utility.hpp" #include "utility.hpp"
#include "cppa/cppa.hpp" #include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp" #include "cppa/sb_actor.hpp"
#include "cppa/detail/thread.hpp"
using std::cout; using std::cout;
using std::cerr; using std::cerr;
...@@ -45,83 +45,64 @@ using std::int64_t; ...@@ -45,83 +45,64 @@ using std::int64_t;
using namespace cppa; using namespace cppa;
struct fsm_receiver : fsm_actor<fsm_receiver> struct fsm_receiver : sb_actor<fsm_receiver> {
{
int64_t m_value; int64_t m_value;
behavior init_state; behavior init_state;
fsm_receiver(int64_t max) : m_value(0) fsm_receiver(int64_t max) : m_value(0) {
{ init_state = (
init_state = on(atom("msg")) >> [=]() {
(
on(atom("msg")) >> [=]()
{
++m_value; ++m_value;
if (m_value == max) if (m_value == max) {
{ quit();
become_void();
} }
} }
); );
} }
}; };
void receiver(int64_t max) void receiver(int64_t max) {
{
int64_t value; int64_t value;
receive_while(gref(value) < max) receive_while(gref(value) < max) (
//receive_while([&]() { return value < max; }) on(atom("msg")) >> [&]() {
(
on(atom("msg")) >> [&]()
{
++value; ++value;
} }
); );
} }
void sender(actor_ptr whom, int64_t count) void sender(actor_ptr whom, int64_t count) {
{
any_tuple msg = make_cow_tuple(atom("msg")); any_tuple msg = make_cow_tuple(atom("msg"));
for (int64_t i = 0; i < count; ++i) for (int64_t i = 0; i < count; ++i) {
{
whom->enqueue(nullptr, msg); whom->enqueue(nullptr, msg);
} }
} }
void usage() void usage() {
{
cout << "usage: mailbox_performance " cout << "usage: mailbox_performance "
"(stacked|event-based) (sending threads) (msg per thread)" << endl "(stacked|event-based) (sending threads) (msg per thread)" << endl
<< endl; << endl;
} }
int main(int argc, char** argv) int main(int argc, char** argv) {
{ if (argc == 4) {
if (argc == 4)
{
int64_t num_sender = rd<int64_t>(argv[2]); int64_t num_sender = rd<int64_t>(argv[2]);
int64_t num_msgs = rd<int64_t>(argv[3]); int64_t num_msgs = rd<int64_t>(argv[3]);
actor_ptr testee; actor_ptr testee;
if (strcmp(argv[1], "stacked") == 0) if (strcmp(argv[1], "stacked") == 0) {
{
testee = spawn(receiver, num_sender * num_msgs); testee = spawn(receiver, num_sender * num_msgs);
} }
else if (strcmp(argv[1], "event-based") == 0) else if (strcmp(argv[1], "event-based") == 0) {
{ testee = spawn<fsm_receiver>(num_sender * num_msgs);
testee = spawn(new fsm_receiver(num_sender * num_msgs));
} }
else else {
{
usage(); usage();
return 1; return 1;
} }
for (int64_t i = 0; i < num_sender; ++i) for (int64_t i = 0; i < num_sender; ++i) {
{ std::thread(sender, testee, num_msgs).detach();
detail::thread(sender, testee, num_msgs).detach();
} }
await_all_others_done(); await_all_others_done();
} }
else else {
{
usage(); usage();
return 1; return 1;
} }
......
...@@ -53,12 +53,10 @@ using std::int64_t; ...@@ -53,12 +53,10 @@ using std::int64_t;
using namespace cppa; using namespace cppa;
template<typename T> template<typename T>
T rd(char const* cstr) T rd(const char* cstr) {
{
char* endptr = nullptr; char* endptr = nullptr;
T result = static_cast<T>(strtol(cstr, &endptr, 10)); T result = static_cast<T>(strtol(cstr, &endptr, 10));
if (endptr == nullptr || *endptr != '\0') if (endptr == nullptr || *endptr != '\0') {
{
std::string errstr; std::string errstr;
errstr += "\""; errstr += "\"";
errstr += cstr; errstr += cstr;
...@@ -68,29 +66,71 @@ T rd(char const* cstr) ...@@ -68,29 +66,71 @@ T rd(char const* cstr)
return result; return result;
} }
int main(int argc, char** argv) void usage() {
{ cerr << "usage: matching (cow_tuple|object_array) {NUM_LOOPS}" << endl;
exit(1);
}
int main(int argc, char** argv) {
announce<list<int>>(); announce<list<int>>();
if (argc != 2) if (argc != 3) usage();
{ auto num_loops = rd<int64_t>(argv[2]);
cerr << "usage: matching {NUM_LOOPS}" << endl; any_tuple m1;
return 1; any_tuple m2;
any_tuple m3;
any_tuple m4;
any_tuple m5;
any_tuple m6;
if (strcmp(argv[1], "cow_tuple") == 0) {
m1 = make_cow_tuple(atom("msg1"), 0);
m2 = make_cow_tuple(atom("msg2"), 0.0);
m3 = make_cow_tuple(atom("msg3"), list<int>{0});
m4 = make_cow_tuple(atom("msg4"), 0, "0");
m5 = make_cow_tuple(atom("msg5"), 0, 0, 0);
m6 = make_cow_tuple(atom("msg6"), 0, 0.0, "0");
}
else if (strcmp(argv[1], "object_array") == 0) {
auto m1o = new detail::object_array;
m1o->push_back(object::from(atom("msg1")));
m1o->push_back(object::from(0));
m1 = any_tuple{m1o};
auto m2o = new detail::object_array;
m2o->push_back(object::from(atom("msg2")));
m2o->push_back(object::from(0.0));
m2 = any_tuple{m2o};
auto m3o = new detail::object_array;
m3o->push_back(object::from(atom("msg3")));
m3o->push_back(object::from(list<int>{0}));
m3 = any_tuple{m3o};
auto m4o = new detail::object_array;
m4o->push_back(object::from(atom("msg4")));
m4o->push_back(object::from(0));
m4o->push_back(object::from(std::string("0")));
m4 = any_tuple{m4o};
auto m5o = new detail::object_array;
m5o->push_back(object::from(atom("msg5")));
m5o->push_back(object::from(0));
m5o->push_back(object::from(0));
m5o->push_back(object::from(0));
m5 = any_tuple{m5o};
auto m6o = new detail::object_array;
m6o->push_back(object::from(atom("msg6")));
m6o->push_back(object::from(0));
m6o->push_back(object::from(0.0));
m6o->push_back(object::from(std::string("0")));
m6 = any_tuple{m6o};
}
else {
usage();
} }
auto num_loops = rd<int64_t>(argv[1]);
any_tuple m1 = make_cow_tuple(atom("msg1"), 0);
any_tuple m2 = make_cow_tuple(atom("msg2"), 0.0);
any_tuple m3 = cppa::make_cow_tuple(atom("msg3"), list<int>{0});
any_tuple m4 = make_cow_tuple(atom("msg4"), 0, "0");
any_tuple m5 = make_cow_tuple(atom("msg5"), 0, 0, 0);
any_tuple m6 = make_cow_tuple(atom("msg6"), 0, 0.0, "0");
int64_t m1matched = 0; int64_t m1matched = 0;
int64_t m2matched = 0; int64_t m2matched = 0;
int64_t m3matched = 0; int64_t m3matched = 0;
int64_t m4matched = 0; int64_t m4matched = 0;
int64_t m5matched = 0; int64_t m5matched = 0;
int64_t m6matched = 0; int64_t m6matched = 0;
auto part_fun = auto part_fun = (
(
on<atom("msg1"), int>() >> [&]() { ++m1matched; }, on<atom("msg1"), int>() >> [&]() { ++m1matched; },
on<atom("msg2"), double>() >> [&]() { ++m2matched; }, on<atom("msg2"), double>() >> [&]() { ++m2matched; },
on<atom("msg3"), list<int> >() >> [&]() { ++m3matched; }, on<atom("msg3"), list<int> >() >> [&]() { ++m3matched; },
...@@ -98,8 +138,7 @@ int main(int argc, char** argv) ...@@ -98,8 +138,7 @@ int main(int argc, char** argv)
on<atom("msg5"), int, int, int>() >> [&]() { ++m5matched; }, on<atom("msg5"), int, int, int>() >> [&]() { ++m5matched; },
on<atom("msg6"), int, double, string>() >> [&]() { ++m6matched; } on<atom("msg6"), int, double, string>() >> [&]() { ++m6matched; }
); );
for (int64_t i = 0; i < num_loops; ++i) for (int64_t i = 0; i < num_loops; ++i) {
{
part_fun(m1); part_fun(m1);
part_fun(m2); part_fun(m2);
part_fun(m3); part_fun(m3);
...@@ -107,4 +146,10 @@ int main(int argc, char** argv) ...@@ -107,4 +146,10 @@ int main(int argc, char** argv)
part_fun(m5); part_fun(m5);
part_fun(m6); part_fun(m6);
} }
assert(m1matched == num_loops);
assert(m2matched == num_loops);
assert(m3matched == num_loops);
assert(m4matched == num_loops);
assert(m5matched == num_loops);
assert(m6matched == num_loops);
} }
This diff is collapsed.
#include <process/process.hpp>
#include <process/dispatch.hpp>
#include "utility.hpp"
typedef std::vector<uint64_t> factors;
constexpr uint64_t s_task_n = uint64_t(86028157)*329545133;
constexpr uint64_t s_factor1 = 86028157;
constexpr uint64_t s_factor2 = 329545133;
void check_factors(const factors& vec)
{
assert(vec.size() == 2);
assert(vec[0] == s_factor1);
assert(vec[1] == s_factor2);
}
class supervisor : public process::Process<supervisor>
{
public:
supervisor(int num_msgs)
: left_(num_msgs)
{
}
void subtract()
{
if (--left_ == 0)
process::terminate(self());
}
void check(const factors& vec)
{
check_factors(vec);
if (--left_ == 0)
process::terminate(self());
}
private:
int left_;
};
class chain_link : public process::Process<chain_link>
{
public:
chain_link()
{
}
chain_link(process::PID<chain_link> pid)
: next_(std::move(pid))
{
}
virtual ~chain_link() { }
virtual void token(int v)
{
assert(next_);
process::dispatch(next_, &chain_link::token, v);
if (v == 0)
process::terminate(self());
}
private:
process::PID<chain_link> next_;
};
class worker : public process::Process<worker>
{
public:
worker(process::PID<supervisor> collector)
: collector_(std::move(collector))
{
}
void calc(uint64_t what)
{
process::dispatch(collector_, &supervisor::check, factorize(what));
}
void done()
{
process::terminate(self());
}
private:
process::PID<supervisor> collector_;
};
class chain_master : public chain_link
{
public:
chain_master(process::PID<supervisor> collector, int rs, int itv, int n)
: chain_link()
, ring_size_(rs)
, initial_value_(itv)
, repetitions_(n)
, iteration_(0)
, collector_(collector)
{
}
void new_ring(int ring_size, int initial_token_value)
{
process::dispatch(worker_, &worker::calc, s_task_n);
next_ = self();
for (int i = 1; i < ring_size; ++i)
next_ = process::spawn(new chain_link(next_), true);
process::dispatch(next_, &chain_link::token, initial_token_value);
}
void init()
{
worker_ = process::spawn(new worker(collector_), true);
new_ring(ring_size_, initial_value_);
}
virtual void token(int t)
{
if (t == 0)
{
if (++iteration_ < repetitions_)
{
new_ring(ring_size_, initial_value_);
}
else
{
dispatch(worker_, &worker::done);
dispatch(collector_, &supervisor::subtract);
process::terminate(self());
}
}
else
{
process::dispatch(next_, &chain_link::token, t - 1);
}
}
private:
const int ring_size_;
const int initial_value_;
const int repetitions_;
int iteration_;
process::PID<supervisor> collector_;
process::PID<chain_link> next_;
process::PID<worker> worker_;
};
int main(int argc, char** argv)
{
if (argc != 5)
{
std::cout << "usage " << argv[0] << ": " <<
"(num rings) (ring size) (initial token value) (repetitions)"
<< std::endl;
return 1;
}
auto iter = argv;
++iter; // argv[0] (app name)
int num_rings = rd<int>(*iter++);
int ring_size = rd<int>(*iter++);
int initial_token_value = rd<int>(*iter++);
int repetitions = rd<int>(*iter++);
int num_msgs = num_rings + (num_rings * repetitions);
auto mc = process::spawn(new supervisor(num_msgs), true);
std::vector<process::PID<chain_master>> masters;
for (int i = 0; i < num_rings; ++i)
{
auto master = process::spawn(
new chain_master(mc, ring_size, initial_token_value, repetitions),
true);
process::dispatch(master, &chain_master::init);
masters.push_back(master);
}
for (auto& m : masters)
process::wait(m);
return 0;
}
#!/bin/bash
# quick & dirty: eval args to enable CXX=... and CXXFLAGS=...
for arg in "$@"; do
eval "$arg"
done
if test "" = "$CXX"; then
CXX=g++
fi
function verbose_exec {
echo $1
eval $1
if test "0" != "$?" ; then
echo ; echo "command failed!"
exit
fi
}
function check_var {
if test "" = "$1" ; then
echo "something went wrong ... $2 not found"
exit
fi
}
function fetch_lib {
find mesos/third_party/libprocess -name "$1"
if test "$2" = "true" ; then
echo "something went wrong ... $1 not found"
fi
}
if ! test -d mesos ; then
echo "fetch mesos (for libprocess)"
verbose_exec "git clone https://github.com/apache/mesos.git"
else
echo "found mesos repository"
fi
LIBFILE=$(fetch_lib libprocess.a)
LIBGLOGFILE=$(fetch_lib libglog.a)
LIBEVFILE=$(fetch_lib libev.a)
echo "LIBFILE=$LIBFILE"
echo "LIBGLOGFILE=$LIBGLOGFILE"
echo "LIBEVFILE=$LIBEVFILE"
if test "" = "$LIBFILE" -o "" = "$LIBGLOGFILE" -o "" = "$LIBEVFILE" ; then
CURR=$PWD
echo "build libprocess"
cd mesos/third_party/libprocess/
verbose_exec "autoreconf -Wnone -i && ./configure CXX=\"$CXX\" CXXFLAGS=\"$CXXFLAGS -D_XOPEN_SOURCE\" && make"
echo "build third_party libraries"
cd third_party
for dir in * ; do
if test -d $dir ; then
# skip boost in third_party directory
if [[ "$dir" == glog* ]] || [[ "$dir" == libev* ]] ; then
echo "cd $dir"
cd $dir
verbose_exec "autoreconf -i ; ./configure CXX=\"$CXX\" CXXFLAGS=\"$CXXFLAGS\" ; make"
echo "cd .."
cd ..
fi
fi
done
cd $CURR
LIBFILE=$(fetch_lib libprocess.a true)
LIBGLOGFILE=$(fetch_lib libglog.a true)
LIBEVFILE=$(fetch_lib libev.a true)
else
echo "found libprocess library: $LIBFILE"
fi
LIBDIRS="-L$(dirname "$LIBFILE") -L$(dirname "$LIBGLOGFILE") -L$(dirname "$LIBEVFILE")"
verbose_exec "$CXX --std=c++0x $CXXFLAGS -Imesos/third_party/libprocess/include/ $LIBDIRS mixed_case_libprocess.cpp -o mixed_case_libprocess -lprocess -lglog -lev"
#!/bin/bash #!/bin/bash
if [[ $# -eq 0 ]] ; then if [[ $# -eq 0 ]] ; then
for i in *.scala; do for i in *.scala; do
echo "scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar \"$i\"" echo "compile \"$i\""
scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar "$i" scalac -unchecked -cp $AKKA_LIBS "$i"
done done
elif [[ $# -eq 1 ]] ; then elif [[ $# -eq 1 ]] ; then
echo "scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar \"$1.scala\"" echo "compile \"$1.scala\""
scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar "$1.scala" scalac -unchecked -cp $AKKA_LIBS "$1.scala"
fi fi
echo done echo done
#!/bin/bash #!/bin/bash
#export JAVA_OPTS="-Xmx1024" #export JAVA_OPTS="-Xmx1024"
#echo "scala -cp /home/neverlord/akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar $@" | ./exec.sh #echo "scala -cp /home/neverlord/akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar $@" | ./exec.sh
echo "scala -cp /home/neverlord/akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar $@" | ./exec.sh JARS=/home/neverlord/akka-microkernel-1.2/lib/akka/activation-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-actor-tests-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-amqp-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-beanstalk-mailbox-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-camel-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-camel-typed-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-dispatcher-extras-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-file-mailbox-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-http-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-kernel-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-mailboxes-common-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-redis-mailbox-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-remote-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-scalaz-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-slf4j-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-spring-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-stm-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-testkit-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/akka-typed-actor-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/amqp-client-2.5.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/aopalliance-1.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/asm-3.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/aspectwerkz-2.2.3.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/beanstalk_client-1.4.5.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/camel-core-2.7.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-cli-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-codec-1.4.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-io-2.0.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-logging-1.1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-management-1.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/commons-pool-1.5.5.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/dispatch-json_2.9.0-0.8.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/guice-all-2.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/h2-lzf-1.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/hawtdispatch-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/hawtdispatch-scala-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jackson-core-asl-1.8.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jackson-mapper-asl-1.8.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jaxb-api-2.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jaxb-impl-2.1.12.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jersey-core-1.3.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jersey-json-1.3.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jersey-scala-1.3.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jersey-server-1.3.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jettison-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-continuation-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-http-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-io-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-security-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-server-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-servlet-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-util-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jetty-xml-7.4.0.v20110414.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jsr250-api-1.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jsr311-api-1.1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/jsr311-api-1.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/junit-4.8.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/log4j-1.2.16.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/multiverse-alpha-0.6.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/netty-3.2.5.Final.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/objenesis-1.2.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/protobuf-java-2.4.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/redisclient_2.9.0-2.3.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/scalaz-core_2.9.0-1-6.0.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/servlet-api-2.5.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/sjson_2.9.0-0.11.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/slf4j-api-1.5.8.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/slf4j-api-1.6.0.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/slf4j-log4j12-1.5.8.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-aop-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-asm-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-beans-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-context-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-core-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/spring-expression-3.0.5.RELEASE.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/stax-api-1.0.1.jar:/home/neverlord/akka-microkernel-1.2/lib/akka/stax-api-1.0-2.jar
echo "scala -cp $JARS $@" | ./exec.sh
...@@ -18,41 +18,33 @@ struct result { uint32_t value; }; ...@@ -18,41 +18,33 @@ struct result { uint32_t value; };
using namespace Theron; using namespace Theron;
struct testee : Actor struct testee : Actor {
{
Address m_parent; Address m_parent;
bool m_first_result_received; bool m_first_result_received;
uint32_t m_first_result; uint32_t m_first_result;
std::vector<ActorRef> m_children; std::vector<ActorRef> m_children;
void spread_handler(const spread& arg, const Address) void spread_handler(const spread& arg, const Address) {
{ if (arg.value == 0) {
if (arg.value == 0)
{
Send(result{1}, m_parent); Send(result{1}, m_parent);
} }
else else {
{
spread msg = {arg.value-1}; spread msg = {arg.value-1};
Parameters params = {GetAddress()}; Parameters params = {GetAddress()};
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i) {
{
m_children.push_back(GetFramework().CreateActor<testee>(params)); m_children.push_back(GetFramework().CreateActor<testee>(params));
m_children.back().Push(msg, GetAddress()); m_children.back().Push(msg, GetAddress());
} }
} }
} }
void result_handler(const result& arg, const Address) void result_handler(const result& arg, const Address) {
{ if (!m_first_result_received) {
if (!m_first_result_received)
{
m_first_result_received = true; m_first_result_received = true;
m_first_result = arg.value; m_first_result = arg.value;
} }
else else {
{
m_children.clear(); m_children.clear();
Send(result{m_first_result + arg.value}, m_parent); Send(result{m_first_result + arg.value}, m_parent);
} }
...@@ -60,25 +52,21 @@ struct testee : Actor ...@@ -60,25 +52,21 @@ struct testee : Actor
typedef struct { Address arg0; } Parameters; typedef struct { Address arg0; } Parameters;
testee(const Parameters& p) : m_parent(p.arg0), m_first_result_received(false) testee(const Parameters& p) : m_parent(p.arg0), m_first_result_received(false) {
{
RegisterHandler(this, &testee::spread_handler); RegisterHandler(this, &testee::spread_handler);
RegisterHandler(this, &testee::result_handler); RegisterHandler(this, &testee::result_handler);
} }
}; };
void usage() void usage() {
{
cout << "usage: theron_actor_creation _ POW" << endl cout << "usage: theron_actor_creation _ POW" << endl
<< " creates 2^POW actors" << endl << " creates 2^POW actors" << endl
<< endl; << endl;
} }
int main(int argc, char** argv) int main(int argc, char** argv) {
{ if (argc != 3) {
if (argc != 3)
{
usage(); usage();
return 1; return 1;
} }
......
...@@ -18,47 +18,39 @@ using namespace Theron; ...@@ -18,47 +18,39 @@ using namespace Theron;
int64_t t_max = 0; int64_t t_max = 0;
struct receiver : Actor struct receiver : Actor {
{
int64_t m_num; int64_t m_num;
void handler(const int64_t&, const Address from) void handler(const int64_t&, const Address from) {
{
if (++m_num == t_max) if (++m_num == t_max)
Send(t_max, from); Send(t_max, from);
} }
receiver() : m_num(0) receiver() : m_num(0) {
{
RegisterHandler(this, &receiver::handler); RegisterHandler(this, &receiver::handler);
} }
}; };
void send_sender(Framework& f, ActorRef ref, Address waiter, int64_t num) void send_sender(Framework& f, ActorRef ref, Address waiter, int64_t num) {
{
auto addr = ref.GetAddress(); auto addr = ref.GetAddress();
int64_t msg; int64_t msg;
for (int64_t i = 0; i < num; ++i) f.Send(msg, waiter, addr); for (int64_t i = 0; i < num; ++i) f.Send(msg, waiter, addr);
} }
void push_sender(Framework& f, ActorRef ref, Address waiter, int64_t num) void push_sender(Framework& f, ActorRef ref, Address waiter, int64_t num) {
{
int64_t msg; int64_t msg;
for (int64_t i = 0; i < num; ++i) ref.Push(msg, waiter); for (int64_t i = 0; i < num; ++i) ref.Push(msg, waiter);
} }
void usage() void usage() {
{
cout << "usage ('push'|'send') (num_threads) (num_messages)" << endl; cout << "usage ('push'|'send') (num_threads) (num_messages)" << endl;
exit(1); exit(1);
} }
int main(int argc, char** argv) int main(int argc, char** argv) {
{ if (argc != 4) {
if (argc != 4)
{
usage(); usage();
} }
enum { invalid_impl, push_impl, send_impl } impl = invalid_impl; enum { invalid_impl, push_impl, send_impl } impl = invalid_impl;
...@@ -74,8 +66,7 @@ int main(int argc, char** argv) ...@@ -74,8 +66,7 @@ int main(int argc, char** argv)
ActorRef aref(framework.CreateActor<receiver>()); ActorRef aref(framework.CreateActor<receiver>());
std::list<std::thread> threads; std::list<std::thread> threads;
auto impl_fun = (impl == push_impl) ? send_sender : push_sender; auto impl_fun = (impl == push_impl) ? send_sender : push_sender;
for (int64_t i = 0; i < num_sender; ++i) for (int64_t i = 0; i < num_sender; ++i) {
{
threads.push_back(std::thread(impl_fun, std::ref(framework), aref, receiverAddr, num_msgs)); threads.push_back(std::thread(impl_fun, std::ref(framework), aref, receiverAddr, num_msgs));
} }
r.Wait(); r.Wait();
......
...@@ -30,40 +30,32 @@ struct master_done { }; ...@@ -30,40 +30,32 @@ struct master_done { };
struct worker_done { }; struct worker_done { };
struct worker : Actor struct worker : Actor {
{ void handle_calc(const calc_msg& msg, Address from) {
void handle_calc(const calc_msg& msg, Address from)
{
factorize(msg.value); factorize(msg.value);
} }
void handle_master_done(const master_done&, Address from) void handle_master_done(const master_done&, Address from) {
{
Send(worker_done(), from); Send(worker_done(), from);
} }
worker() worker() {
{
RegisterHandler(this, &worker::handle_calc); RegisterHandler(this, &worker::handle_calc);
RegisterHandler(this, &worker::handle_master_done); RegisterHandler(this, &worker::handle_master_done);
} }
}; };
struct chain_link : Actor struct chain_link : Actor {
{
Address next; Address next;
void handle_token(const token_msg& msg, Address) void handle_token(const token_msg& msg, Address) {
{
Send(msg, next); Send(msg, next);
} }
typedef struct { Address next; } Parameters; typedef struct { Address next; } Parameters;
chain_link(const Parameters& p) : next(p.next) chain_link(const Parameters& p) : next(p.next) {
{
RegisterHandler(this, &chain_link::handle_token); RegisterHandler(this, &chain_link::handle_token);
} }
}; };
struct master : Actor struct master : Actor {
{
Address mc; Address mc;
int iteration; int iteration;
int max_iterations; int max_iterations;
...@@ -72,20 +64,17 @@ struct master : Actor ...@@ -72,20 +64,17 @@ struct master : Actor
int ring_size; int ring_size;
int initial_token_value; int initial_token_value;
std::vector<ActorRef> m_children; std::vector<ActorRef> m_children;
void new_ring() void new_ring() {
{
m_children.clear(); m_children.clear();
w.Push(calc_msg{s_task_n}, GetAddress()); w.Push(calc_msg{s_task_n}, GetAddress());
next = GetAddress(); next = GetAddress();
for (int i = 1; i < ring_size; ++i) for (int i = 1; i < ring_size; ++i) {
{
m_children.push_back(GetFramework().CreateActor<chain_link>(chain_link::Parameters{next})); m_children.push_back(GetFramework().CreateActor<chain_link>(chain_link::Parameters{next}));
next = m_children.back().GetAddress(); next = m_children.back().GetAddress();
} }
Send(token_msg{initial_token_value}, next); Send(token_msg{initial_token_value}, next);
} }
void handle_init(const init_msg& msg, Address) void handle_init(const init_msg& msg, Address) {
{
w = GetFramework().CreateActor<worker>(); w = GetFramework().CreateActor<worker>();
iteration = 0; iteration = 0;
ring_size = msg.ring_size; ring_size = msg.ring_size;
...@@ -93,40 +82,32 @@ struct master : Actor ...@@ -93,40 +82,32 @@ struct master : Actor
max_iterations = msg.iterations; max_iterations = msg.iterations;
new_ring(); new_ring();
} }
void handle_token(const token_msg& msg, Address) void handle_token(const token_msg& msg, Address) {
{ if (msg.value == 0) {
if (msg.value == 0) if (++iteration < max_iterations) {
{
if (++iteration < max_iterations)
{
new_ring(); new_ring();
} }
else else {
{
w.Push(master_done(), GetAddress()); w.Push(master_done(), GetAddress());
} }
} }
else else {
{
Send(token_msg{msg.value - 1}, next); Send(token_msg{msg.value - 1}, next);
} }
} }
void handle_worker_done(const worker_done&, Address) void handle_worker_done(const worker_done&, Address) {
{
Send(master_done(), mc); Send(master_done(), mc);
w = ActorRef::Null(); w = ActorRef::Null();
} }
typedef struct { Address mc; } Parameters; typedef struct { Address mc; } Parameters;
master(const Parameters& p) : mc(p.mc), iteration(0) master(const Parameters& p) : mc(p.mc), iteration(0) {
{
RegisterHandler(this, &master::handle_init); RegisterHandler(this, &master::handle_init);
RegisterHandler(this, &master::handle_token); RegisterHandler(this, &master::handle_token);
RegisterHandler(this, &master::handle_worker_done); RegisterHandler(this, &master::handle_worker_done);
} }
}; };
void usage() void usage() {
{
cout << "usage: mailbox_performance " cout << "usage: mailbox_performance "
"'send' (num rings) (ring size) " "'send' (num rings) (ring size) "
"(initial token value) (repetitions)" "(initial token value) (repetitions)"
...@@ -135,8 +116,7 @@ void usage() ...@@ -135,8 +116,7 @@ void usage()
exit(1); exit(1);
} }
int main(int argc, char** argv) int main(int argc, char** argv) {
{
if (argc != 6) usage(); if (argc != 6) usage();
if (strcmp("send", argv[1]) != 0) usage(); if (strcmp("send", argv[1]) != 0) usage();
int num_rings = rd<int>(argv[2]); int num_rings = rd<int>(argv[2]);
...@@ -146,12 +126,10 @@ int main(int argc, char** argv) ...@@ -146,12 +126,10 @@ int main(int argc, char** argv)
Receiver r; Receiver r;
Framework framework(num_cores()); Framework framework(num_cores());
std::vector<ActorRef> masters; std::vector<ActorRef> masters;
for (int i = 0; i < num_rings; ++i) for (int i = 0; i < num_rings; ++i) {
{
masters.push_back(framework.CreateActor<master>(master::Parameters{r.GetAddress()})); masters.push_back(framework.CreateActor<master>(master::Parameters{r.GetAddress()}));
} }
for (ActorRef& m : masters) for (ActorRef& m : masters) {
{
m.Push(init_msg{ring_size, inital_token_value, repetitions}, r.GetAddress()); m.Push(init_msg{ring_size, inital_token_value, repetitions}, r.GetAddress());
} }
for (int i = 0; i < num_rings; ++i) r.Wait(); for (int i = 0; i < num_rings; ++i) r.Wait();
......
...@@ -32,18 +32,35 @@ ...@@ -32,18 +32,35 @@
#define UTILITY_HPP #define UTILITY_HPP
#include <vector> #include <vector>
#include <string>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
#include "boost/thread.hpp" inline std::vector<std::string> split(const std::string& str, char delim) {
std::vector<std::string> result;
std::stringstream strs{str};
std::string tmp;
while (std::getline(strs, tmp, delim)) result.push_back(tmp);
return result;
}
inline std::string join(const std::vector<std::string>& vec,
const std::string& delim = "") {
if (vec.empty()) return "";
auto result = vec.front();
for (auto i = vec.begin() + 1; i != vec.end(); ++i) {
result += delim;
result += *i;
}
return result;
}
template<typename T> template<typename T>
T rd(char const* cstr) T rd(const char* cstr) {
{
char* endptr = nullptr; char* endptr = nullptr;
T result = static_cast<T>(strtol(cstr, &endptr, 10)); T result = static_cast<T>(strtol(cstr, &endptr, 10));
if (endptr == nullptr || *endptr != '\0') if (endptr == nullptr || *endptr != '\0') {
{
std::string errstr; std::string errstr;
errstr += "\""; errstr += "\"";
errstr += cstr; errstr += cstr;
...@@ -53,18 +70,10 @@ T rd(char const* cstr) ...@@ -53,18 +70,10 @@ T rd(char const* cstr)
return result; return result;
} }
#ifdef __APPLE__ int num_cores() {
int num_cores()
{
return static_cast<int>(boost::thread::hardware_concurrency());
}
#else
int num_cores()
{
char cbuf[100]; char cbuf[100];
FILE* cmd = popen("/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l", "r"); FILE* cmd = popen("/bin/cat /proc/cpuinfo | /bin/grep processor | /usr/bin/wc -l", "r");
if (fgets(cbuf, 100, cmd) == 0) if (fgets(cbuf, 100, cmd) == 0) {
{
throw std::runtime_error("cannot determine number of cores"); throw std::runtime_error("cannot determine number of cores");
} }
pclose(cmd); pclose(cmd);
...@@ -73,26 +82,20 @@ int num_cores() ...@@ -73,26 +82,20 @@ int num_cores()
*i = '\0'; *i = '\0';
return rd<int>(cbuf); return rd<int>(cbuf);
} }
#endif
std::vector<uint64_t> factorize(uint64_t n) std::vector<uint64_t> factorize(uint64_t n) {
{
std::vector<uint64_t> result; std::vector<uint64_t> result;
if (n <= 3) if (n <= 3) {
{
result.push_back(n); result.push_back(n);
return std::move(result); return std::move(result);
} }
uint64_t d = 2; uint64_t d = 2;
while(d < n) while(d < n) {
{ if((n % d) == 0) {
if((n % d) == 0)
{
result.push_back(d); result.push_back(d);
n /= d; n /= d;
} }
else else {
{
d = (d == 2) ? 3 : (d + 2); d = (d == 2) ? 3 : (d + 2);
} }
} }
......
This diff is collapsed.
ACLOCAL_AMFLAGS = -I ../m4
bin_PROGRAMS = cppatest
cppatest_SOURCES = \
../src/abstract_tuple.cpp \
../src/abstract_type_list.cpp \
../src/actor_behavior.cpp \
../src/actor_count.cpp \
../src/actor.cpp \
../src/actor_proxy_cache.cpp \
../src/actor_proxy.cpp \
../src/actor_registry.cpp \
../src/addressed_message.cpp \
../src/any_tuple.cpp \
../src/any_tuple_iterator.cpp \
../src/atom.cpp \
../src/attachable.cpp \
../src/binary_deserializer.cpp \
../src/binary_serializer.cpp \
../src/blocking_message_queue.cpp \
../src/channel.cpp \
../src/local_actor.cpp \
../src/converted_thread_context.cpp \
../src/cppa.cpp \
../src/delegate.cpp \
../src/demangle.cpp \
../src/deserializer.cpp \
../src/duration.cpp \
../src/empty_tuple.cpp \
../src/exception.cpp \
../src/fiber.cpp \
../src/group.cpp \
../src/group_manager.cpp \
../src/intermediate.cpp \
../src/invokable.cpp \
../src/invoke_rules.cpp \
../src/mailman.cpp \
../src/matcher_arguments.cpp \
../src/message_queue.cpp \
../src/mock_scheduler.cpp \
../src/native_socket.cpp \
../src/network_manager.cpp \
../src/object_array.cpp \
../src/object.cpp \
../src/post_office.cpp \
../src/post_office_msg.cpp \
../src/primitive_variant.cpp \
../src/process_information.cpp \
../src/ripemd_160.cpp \
../src/scheduled_actor.cpp \
../src/scheduler.cpp \
../src/serializer.cpp \
../src/shared_spinlock.cpp \
../src/singleton_manager.cpp \
../src/string_serialization.cpp \
../src/task_scheduler.cpp \
../src/thread_pool_scheduler.cpp \
../src/to_uniform_name.cpp \
../src/unicast_network.cpp \
../src/uniform_type_info.cpp \
../src/yielding_message_queue.cpp \
../src/yield_interface.cpp \
../unit_testing/hash_of.cpp \
../unit_testing/main.cpp \
../unit_testing/ping_pong.cpp \
../unit_testing/test__a_matches_b.cpp \
../unit_testing/test__atom.cpp \
../unit_testing/test__intrusive_ptr.cpp \
../unit_testing/test__local_group.cpp \
../unit_testing/test__primitive_variant.cpp \
../unit_testing/test__remote_actor.cpp \
../unit_testing/test__ripemd_160.cpp \
../unit_testing/test__serialization.cpp \
../unit_testing/test__spawn.cpp \
../unit_testing/test__tuple.cpp \
../unit_testing/test__type_list.cpp \
../unit_testing/test__uniform_type.cpp \
../unit_testing/test__yield_interface.cpp
AM_CPPFLAGS = -I../
cppatest_CXXFLAGS = --std=c++0x -pedantic -Wall -Wextra
#AM_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
cppatest_LDADD = $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <stdio.h>
#include <ucontext.h>
#include <sys/mman.h>
#include <signal.h>
#include <stddef.h>
static ucontext_t ctx[2];
__thread int m_count = 0;
void coroutine()
{
for (;;)
{
++m_count;
printf("m_count = %i\n", m_count);
swapcontext(&ctx[1], &ctx[0]);
}
}
int main(int argc, char** argv)
{
int i;
void* coroutine_stack = mmap(0,
SIGSTKSZ,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON,
-1,
0);
memset(&ctx[0], 0, sizeof(ucontext_t));
getcontext(&ctx[0]);
memset(&ctx[1], 0, sizeof(ucontext_t));
getcontext(&ctx[1]);
ctx[1].uc_stack.ss_sp = coroutine_stack;
ctx[1].uc_stack.ss_size = SIGSTKSZ;
ctx[1].uc_link = &ctx[0];
makecontext(&ctx[1], coroutine, 0);
for (i = 1; i < 11; ++i)
{
printf("i = %i\n", i);
swapcontext(&ctx[0], &ctx[1]);
}
munmap(coroutine_stack, SIGSTKSZ);
return 0;
}
AC_PREREQ([2.6])
AC_INIT([cppatest], [0.1])
AM_INIT_AUTOMAKE(@PACKAGE_NAME@, @PACKAGE_VERSION@)
AC_CONFIG_MACRO_DIR([../m4])
AC_PROG_CXX
# check for boost and boost_thread
AX_BOOST_BASE([1.42.0])
AX_BOOST_THREAD
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#include <iostream>
#include "cppa_fibre.h"
using std::cout;
using std::endl;
struct pseudo_worker
{
int m_value;
pseudo_worker() : m_value(0) { }
void operator()()
{
for (;;)
{
++m_value;
cout << "value = " << m_value << endl;
cppa_fibre_yield(0);
}
}
};
void coroutine()
{
auto pw = reinterpret_cast<pseudo_worker*>(cppa_fibre_init_switch_arg());
(*pw)();
}
int main()
{
pseudo_worker pw;
cppa_fibre fself;
cppa_fibre fcoroutine;
cppa_fibre_ctor(&fself);
cppa_fibre_ctor2(&fcoroutine, coroutine, &pw);
cppa_fibre_initialize(&fcoroutine);
for (int i = 1; i < 11; ++i)
{
cout << "i = " << i << endl;
cppa_fibre_switch(&fself, &fcoroutine);
}
cppa_fibre_dtor(&fself);
cppa_fibre_dtor(&fcoroutine);
return 0;
}
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <ucontext.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <signal.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "cppa_fibre.h"
__thread void* s_switch_arg;
__thread int s_yield_value;
__thread ucontext_t* s_caller;
__thread ucontext_t* s_callee;
void cppa_fibre_ctor(cppa_fibre* instance)
{
instance->m_state = 0;
memset(&(instance->m_context), 0, sizeof(ucontext_t));
getcontext(&(instance->m_context));
instance->m_fun = 0;
instance->m_init_arg = 0;
}
void cppa_fibre_ctor2(cppa_fibre* instance, void (*fun)(), void* arg)
{
cppa_fibre_ctor(instance);
instance->m_state = 1;
instance->m_fun = fun;
instance->m_init_arg = arg;
}
void cppa_fibre_initialize(cppa_fibre* instance)
{
if (instance->m_state == 1)
{
instance->m_state = 2;
instance->m_context.uc_stack.ss_sp = mmap(0,
SIGSTKSZ,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON,
-1,
0);
instance->m_context.uc_stack.ss_size = SIGSTKSZ;
makecontext(&(instance->m_context), instance->m_fun, 0);
s_switch_arg = instance->m_init_arg;
}
}
void cppa_fibre_dtor(cppa_fibre* instance)
{
if (instance->m_state == 2)
{
munmap(instance->m_context.uc_stack.ss_sp, SIGSTKSZ);
}
}
void* cppa_fibre_init_switch_arg()
{
return s_switch_arg;
}
void cppa_fibre_switch(cppa_fibre* from, cppa_fibre* to)
{
ucontext_t* ctx_from = &(from->m_context);
ucontext_t* ctx_to = &(to->m_context);
s_caller = ctx_from;
s_callee = ctx_to;
swapcontext(ctx_from, ctx_to);
}
void cppa_fibre_yield(int value)
{
s_yield_value = value;
swapcontext(s_callee, s_caller);
}
int cppa_fibre_yielded_value()
{
return s_yield_value;
}
#ifndef CPPA_FIBRE_H
#define CPPA_FIBRE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <stdio.h>
#include <ucontext.h>
struct cppa_fibre_struct
{
// 0: *this* context
// 1: fibre with function to execute, no stack assigned yet
// 2: as 1 but with assigned stack
int m_state;
ucontext_t m_context;
void (*m_fun)();
void* m_init_arg;
};
typedef struct cppa_fibre_struct cppa_fibre;
void cppa_fibre_ctor(cppa_fibre* instance);
/*
* @brief Initializes the given fibre.
* @param instance Pointer to an uninitialized object.
* @param fun Function this fibre should execute.
* @param switch_arg This pointer is stored in a
* thread-local variable on first
* context switch to @p instance.
*/
void cppa_fibre_ctor2(cppa_fibre* instance,
void (*fun)(),
void* switch_arg);
/*
* @warning call directly before the first switch
*/
void cppa_fibre_initialize(cppa_fibre* instance);
void cppa_fibre_dtor(cppa_fibre* instance);
/*
* @brief Returns
*/
void* cppa_fibre_init_switch_arg();
void cppa_fibre_switch(cppa_fibre* from, cppa_fibre* to);
/*
* Switches back to the calling fibre.
*/
void cppa_fibre_yield(int value);
/*
* Gets the yielded value of the client fibre.
*/
int cppa_fibre_yielded_value();
#ifdef __cplusplus
}
#endif
#endif
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest:
\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing
\"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
AC_PREREQ([2.6])
AC_INIT([libcppa], [0.1])
AM_INIT_AUTOMAKE(@PACKAGE_NAME@, @PACKAGE_VERSION@)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src])
AC_PROG_CXX
# check for boost and boost_thread
AX_BOOST_BASE([1.42.0])
AX_BOOST_THREAD
AC_PROG_LIBTOOL
# check for C++0x compatibility
AC_LANG([C++])
ORIGINAL_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -Werror -std=c++0x"
AC_CACHE_CHECK(
[whether C++ compiler supports variadic templates],
[ac_cv_cpp_variadic_templates],
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include "variadic_templates_test.cpp"]])],
[ac_cv_cpp_variadic_templates=yes],
[ac_cv_cpp_variadic_templates=no]))
#AC_CACHE_CHECK(
# [whether C++ compiler supports nullptr],
# [ac_cv_cpp_nullptr],
# AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static void* myptr = nullptr;]])],
# [ac_cv_cpp_nullptr=yes],
# [ac_cv_cpp_nullptr=no]))
AS_IF(
[test "x$ac_cv_cpp_variadic_templates" = "xyes" ],
[],
[AC_MSG_ERROR([at least one required C++ compiler feature is not supported])])
CPPFLAGS="$ORIGINAL_CPPFLAGS"
# environment
AC_ARG_VAR([NO_VERSIONED_INCLUDE_DIR], [set this to 1 in order to install headers into <prefix>/cppa/ rather than into <prefix>/cppa/<version>/cppa/])
AM_CONDITIONAL([VERSIONED_INCLUDE_DIR], [test "x$NO_VERSIONED_INCLUDE_DIR" != "x1"])
AC_CONFIG_FILES([Makefile unit_testing/Makefile examples/Makefile benchmarks/Makefile libcppa.pc])
AC_OUTPUT
This diff is collapsed.
/Users/neverlord/libcppa .
/home/neverlord/libcppa ./unit_testing
./third_party/boost_context/include/
/opt/local/include/gcc46/c++ /opt/local/include/gcc46/c++
/opt/local/include/ /opt/local/include/
/Users/neverlord/libcppa/unit_testing
/home/neverlord/libcppa/unit_testing
This diff is collapsed.
...@@ -28,25 +28,24 @@ ...@@ -28,25 +28,24 @@
\******************************************************************************/ \******************************************************************************/
#ifndef ACTOR_PROXY_HPP #ifndef CPPA_ACTOR_PROXY_HPP
#define ACTOR_PROXY_HPP #define CPPA_ACTOR_PROXY_HPP
#include "cppa/actor.hpp" #include "cppa/actor.hpp"
#include "cppa/abstract_actor.hpp" #include "cppa/detail/abstract_actor.hpp"
namespace cppa { namespace cppa {
#ifdef CPPA_DOCUMENTATION #ifdef CPPA_DOCUMENTATION
/** /**
* @brief Represents a remote Actor. * @brief Represents a remote actor.
*/ */
class actor_proxy : public actor { }; class actor_proxy : public actor { };
#else // CPPA_DOCUMENTATION #else // CPPA_DOCUMENTATION
class actor_proxy : public abstract_actor<actor> class actor_proxy : public detail::abstract_actor<actor> {
{
typedef abstract_actor<actor> super; typedef abstract_actor<actor> super;
...@@ -54,19 +53,17 @@ class actor_proxy : public abstract_actor<actor> ...@@ -54,19 +53,17 @@ class actor_proxy : public abstract_actor<actor>
actor_proxy(std::uint32_t mid, const process_information_ptr& parent); actor_proxy(std::uint32_t mid, const process_information_ptr& parent);
void enqueue(actor* sender, any_tuple&& msg); void enqueue(actor* sender, any_tuple msg);
void enqueue(actor* sender, const any_tuple& msg);
void link_to(intrusive_ptr<actor>& other); void link_to(intrusive_ptr<actor>& other);
// do not cause to send this actor an ":Unlink" message // do not cause to send this actor an "UNLINK" message
// to the "original" remote actor // to the "original" remote actor
void local_link_to(intrusive_ptr<actor>& other); void local_link_to(intrusive_ptr<actor>& other);
void unlink_from(intrusive_ptr<actor>& other); void unlink_from(intrusive_ptr<actor>& other);
// do not cause to send this actor an ":Unlink" message // do not cause to send this actor an "UNLINK" message
// to the "original" remote actor // to the "original" remote actor
void local_unlink_from(intrusive_ptr<actor>& other); void local_unlink_from(intrusive_ptr<actor>& other);
...@@ -76,15 +73,18 @@ class actor_proxy : public abstract_actor<actor> ...@@ -76,15 +73,18 @@ class actor_proxy : public abstract_actor<actor>
public: public:
void forward_message(const process_information_ptr&, void forward_message(const process_information_ptr&, actor*, any_tuple&&);
actor*, const any_tuple&);
}; };
#endif // CPPA_DOCUMENTATION #endif // CPPA_DOCUMENTATION
/**
* @brief A smart pointer to an {@link actor_proxy} instance.
* @relates actor_proxy
*/
typedef intrusive_ptr<actor_proxy> actor_proxy_ptr; typedef intrusive_ptr<actor_proxy> actor_proxy_ptr;
} // namespace cppa } // namespace cppa
#endif // ACTOR_PROXY_HPP #endif // CPPA_ACTOR_PROXY_HPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
\******************************************************************************/ \******************************************************************************/
#ifndef ACTOR_COUNT_HPP #ifndef CPPA_ACTOR_COUNT_HPP
#define ACTOR_COUNT_HPP #define CPPA_ACTOR_COUNT_HPP
#include <cstddef> #include <cstddef>
...@@ -45,4 +45,4 @@ void actor_count_wait_until(size_t expected); ...@@ -45,4 +45,4 @@ void actor_count_wait_until(size_t expected);
} } // namespace cppa::detail } } // namespace cppa::detail
#endif // ACTOR_COUNT_HPP #endif // CPPA_ACTOR_COUNT_HPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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