Commit d9c92d31 authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'unstable' of github.com:Neverlord/libcppa into unstable

parents 07b27254 bfc843db
......@@ -3,7 +3,7 @@ project(cppa CXX)
set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 5)
set(LIBCPPA_VERSION_PATCH 4)
set(LIBCPPA_VERSION_PATCH 5)
# prohibit in-source builds
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
......
Version 0.5.5
-------------
__2013_01_07__
- Cover `aout` in manual
- Solved bug in chaining implementation
- Added support for Boost.Context 1.51
- Use `memory::create` rather than `new` for all actors
- Simplified invoke process of `match_expr`
Version 0.5.4
-------------
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = libcppa
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = "Version 0.5.4"
PROJECT_NUMBER = "Version 0.5.5"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......
......@@ -62,7 +62,7 @@ class actor_companion_mixin : public Base {
template<typename... Args>
actor_companion_mixin(Args&&... args) : super(std::forward<Args>(args)...) {
m_self.reset(new companion(this));
m_self.reset(detail::memory::create<companion>(this));
}
~actor_companion_mixin() {
......
......@@ -37,6 +37,7 @@
#include "cppa/event_based_actor.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/memory.hpp"
#include "cppa/util/type_list.hpp"
namespace cppa { namespace detail {
......@@ -103,8 +104,8 @@ class event_based_actor_factory {
template<typename... Args>
actor_ptr spawn(Args&&... args) {
return get_scheduler()->spawn(new impl(m_init, m_on_exit,
std::forward<Args>(args)...));
return get_scheduler()->spawn(memory::create<impl>(m_init, m_on_exit,
std::forward<Args>(args)...));
}
private:
......
......@@ -633,15 +633,15 @@ class match_expr {
init();
}
bool invoke(const any_tuple& tup) {
inline bool invoke(const any_tuple& tup) {
return invoke_impl(tup);
}
bool invoke(any_tuple& tup) {
inline bool invoke(any_tuple& tup) {
return invoke_impl(tup);
}
bool invoke(any_tuple&& tup) {
inline bool invoke(any_tuple&& tup) {
any_tuple tmp{tup};
return invoke_impl(tmp);
}
......@@ -658,15 +658,15 @@ class match_expr {
tup);
}
bool operator()(const any_tuple& tup) {
inline bool operator()(const any_tuple& tup) {
return invoke_impl(tup);
}
bool operator()(any_tuple& tup) {
inline bool operator()(any_tuple& tup) {
return invoke_impl(tup);
}
bool operator()(any_tuple&& tup) {
inline bool operator()(any_tuple&& tup) {
any_tuple tmp{tup};
return invoke_impl(tmp);
}
......
......@@ -39,19 +39,19 @@
namespace cppa { namespace util {
template<typename F, class Tuple, long... Is>
auto apply_args(F& f, Tuple& tup, util::int_list<Is...>)
inline auto apply_args(F& f, Tuple& tup, util::int_list<Is...>)
-> decltype(f(get_cv_aware<Is>(tup)...)) {
return f(get_cv_aware<Is>(tup)...);
}
template<typename F, class Tuple, long... Is, typename... Args>
auto apply_args_prefixed(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args)
inline auto apply_args_prefixed(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args)
-> decltype(f(std::forward<Args>(args)..., get_cv_aware<Is>(tup)...)) {
return f(std::forward<Args>(args)..., get_cv_aware<Is>(tup)...);
}
template<typename F, class Tuple, long... Is, typename... Args>
auto apply_args_suffxied(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args)
inline auto apply_args_suffxied(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args)
-> decltype(f(get_cv_aware<Is>(tup)..., std::forward<Args>(args)...)) {
return f(get_cv_aware<Is>(tup)..., std::forward<Args>(args)...);
}
......@@ -59,7 +59,7 @@ auto apply_args_suffxied(F& f, Tuple& tup, util::int_list<Is...>, Args&&... args
template<typename Result, size_t NumFunctorArgs, size_t NumArgs>
struct partially_apply_helper {
template<class Fun, typename Arg0, typename... Args>
static Result _(const Fun& fun, Arg0&&, Args&&... args) {
static inline Result _(const Fun& fun, Arg0&&, Args&&... args) {
return partially_apply_helper<Result, NumFunctorArgs, sizeof...(Args)>
::_(fun, std::forward<Args>(args)...);
}
......@@ -68,13 +68,13 @@ struct partially_apply_helper {
template<typename Result, size_t X>
struct partially_apply_helper<Result, X, X> {
template<class Fun, typename... Args>
static Result _(const Fun& fun, Args&&... args) {
static inline Result _(const Fun& fun, Args&&... args) {
return fun(std::forward<Args>(args)...);
}
};
template<typename Result, size_t Num, typename F, typename... Args>
Result partially_apply(F& f, Args&&... args) {
inline Result partially_apply(F& f, Args&&... args) {
return partially_apply_helper<Result,Num,sizeof...(Args)>
::_(f, std::forward<Args>(args)...);
}
......
No preview for this file type
......@@ -127,10 +127,12 @@ class scheduler_helper {
typedef intrusive_ptr<thread_mapped_actor> ptr_type;
void start() {
ptr_type mtimer{new thread_mapped_actor};
ptr_type mprinter{new thread_mapped_actor};
ptr_type mtimer{detail::memory::create<thread_mapped_actor>()};
ptr_type mprinter{detail::memory::create<thread_mapped_actor>()};
// launch threads
m_timer_thread = std::thread(&scheduler_helper::timer_loop, mtimer);
m_printer_thread = std::thread(&scheduler_helper::printer_loop, mprinter);
// set member variables
m_timer = mtimer;
m_printer = mprinter;
}
......@@ -291,9 +293,10 @@ void scheduler_helper::printer_loop(ptr_type m_self) {
);
}
scheduler::scheduler() : m_helper(new scheduler_helper) { }
scheduler::scheduler() : m_helper(nullptr) { }
void scheduler::initialize() {
m_helper = new scheduler_helper;
m_helper->start();
}
......
......@@ -44,7 +44,7 @@ pthread_key_t s_key;
pthread_once_t s_key_once = PTHREAD_ONCE_INIT;
local_actor* tss_constructor() {
local_actor* result = new thread_mapped_actor;
local_actor* result = detail::memory::create<thread_mapped_actor>();
result->ref();
get_scheduler()->register_converted_context(result);
return result;
......
......@@ -205,7 +205,7 @@ actor_ptr thread_pool_scheduler::spawn_as_thread(void_function fun,
init_callback cb,
bool hidden) {
if (!hidden) inc_actor_count();
thread_mapped_actor_ptr ptr{new thread_mapped_actor(std::move(fun))};
thread_mapped_actor_ptr ptr{detail::memory::create<thread_mapped_actor>(std::move(fun))};
ptr->init();
ptr->initialized(true);
cb(ptr.get());
......@@ -257,7 +257,7 @@ actor_ptr thread_pool_scheduler::spawn(scheduled_actor* raw,
actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint) {
if (hint == scheduled || hint == scheduled_and_hidden) {
scheduled_actor_ptr ptr{new context_switching_actor(std::move(fun))};
scheduled_actor_ptr ptr{detail::memory::create<context_switching_actor>(std::move(fun))};
ptr->attach_to_scheduler(this, hint == scheduled_and_hidden);
return spawn_impl(std::move(ptr));
}
......@@ -267,11 +267,12 @@ actor_ptr thread_pool_scheduler::spawn(void_function fun, scheduling_hint hint)
hint == detached_and_hidden);
}
}
actor_ptr thread_pool_scheduler::spawn(void_function fun,
init_callback init_cb,
scheduling_hint hint) {
if (hint == scheduled || hint == scheduled_and_hidden) {
scheduled_actor_ptr ptr{new context_switching_actor(std::move(fun))};
scheduled_actor_ptr ptr{detail::memory::create<context_switching_actor>(std::move(fun))};
ptr->attach_to_scheduler(this, hint == scheduled_and_hidden);
init_cb(ptr.get());
return spawn_impl(std::move(ptr));
......
......@@ -484,6 +484,7 @@ int main() {
await_all_others_done();
CPPA_IF_VERBOSE(cout << "ok" << endl);
CPPA_IF_VERBOSE(cout << "test sync send with factory spawned actor ... " << flush);
auto sync_testee_factory = factory::event_based(
[&]() {
self->become (
......@@ -510,25 +511,39 @@ int main() {
);
}
);
CPPA_CHECK(true);
auto sync_testee = sync_testee_factory.spawn();
self->monitor(sync_testee);
send(sync_testee, "hi");
receive (
on("whassup?") >> []() {
on("whassup?") >> [&] {
CPPA_CHECK(true);
// this is NOT a reply, it's just an asynchronous message
send(self->last_sender(), "a lot!");
reply("nothing");
}
);
receive (
on("goodbye!") >> []() { }
on("goodbye!") >> [&] {
CPPA_CHECK(true);
}
);
CPPA_CHECK(true);
receive (
on(atom("DOWN"), exit_reason::normal) >> [&] {
CPPA_CHECK(self->last_sender() == sync_testee);
}
);
await_all_others_done();
CPPA_IF_VERBOSE(cout << "ok" << endl);
receive_response(sync_send(sync_testee, "!?")) (
others() >> [&]() {
CPPA_ERROR("'sync_testee' still alive?");
},
after(chrono::milliseconds(5)) >> []() { }
after(chrono::milliseconds(5)) >> [&] {
CPPA_CHECK(true);
}
);
auto inflater = factory::event_based(
......@@ -547,10 +562,12 @@ int main() {
auto bob = inflater.spawn("Bob", joe);
send(bob, 1, "hello actor");
receive (
on(4, "hello actor") >> []() {
on(4, "hello actor") >> [&] {
CPPA_CHECK(true);
// done
},
others() >> [] {
others() >> [&] {
CPPA_ERROR("unexpected result");
cerr << "unexpected: " << to_string(self->last_dequeued()) << endl;
}
);
......
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