Commit 82b23a81 authored by Dominik Charousset's avatar Dominik Charousset

removed dependency to scheduler

this patch removes the dependency to scheduler.hpp from send.hpp
by moving delayed_* functions to send.cpp
parent e2675619
......@@ -157,6 +157,7 @@ set(LIBCPPA_SRC
src/scheduled_actor.cpp
src/scheduled_actor_dummy.cpp
src/scheduler.cpp
src/send.cpp
src/self.cpp
src/serializer.cpp
src/shared_spinlock.cpp
......
......@@ -34,11 +34,12 @@
#include "cppa/self.hpp"
#include "cppa/actor.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/local_actor.hpp"
#include "cppa/message_header.hpp"
#include "cppa/message_future.hpp"
#include "cppa/util/duration.hpp"
namespace cppa {
/**
......@@ -147,6 +148,63 @@ inline message_future sync_send(actor_ptr whom, Ts&&... what) {
make_any_tuple(std::forward<Ts>(what)...));
}
/**
* @brief Sends a message to @p whom that is delayed by @p rel_time.
* @param whom Receiver of the message.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
*/
void delayed_send_tuple(const channel_ptr& to,
const util::duration& rel_time,
any_tuple data);
/**
* @brief Sends a message to @p whom that is delayed by @p rel_time.
* @param whom Receiver of the message.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_send_tuple(const channel_ptr& whom,
const std::chrono::duration<Rep, Period>& rtime,
any_tuple what) {
delayed_send_tuple(whom, util::duration{rtime}, std::move(what));
}
/**
* @brief Sends a reply message that is delayed by @p rel_time.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
* @see delayed_send()
*/
void delayed_reply_tuple(const util::duration& rel_time,
message_id mid,
any_tuple data);
/**
* @brief Sends a reply message that is delayed by @p rel_time.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
* @see delayed_send()
*/
void delayed_reply_tuple(const util::duration& rel_time, any_tuple data);
/**
* @brief Sends a reply message that is delayed by @p rel_time.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
* @see delayed_send()
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_reply_tuple(const std::chrono::duration<Rep, Period>& rtime,
any_tuple what) {
delayed_reply_tuple(util::duration{rtime}, std::move(what));
}
/**
* @brief Sends @p what as a synchronous message to @p whom with a timeout.
*
......@@ -165,7 +223,7 @@ message_future timed_sync_send_tuple(actor_ptr whom,
any_tuple what) {
auto mf = sync_send_tuple(std::move(whom), std::move(what));
auto tmp = make_any_tuple(atom("TIMEOUT"));
get_scheduler()->delayed_reply(self, rel_time, mf.id(), std::move(tmp));
delayed_reply_tuple(util::duration{rel_time}, mf.id(), std::move(tmp));
return mf;
}
......@@ -236,20 +294,6 @@ inline void forward_to(const actor_ptr& whom) {
self->forward_message(whom);
}
/**
* @brief Sends a message to @p whom that is delayed by @p rel_time.
* @param whom Receiver of the message.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_send_tuple(const channel_ptr& whom,
const std::chrono::duration<Rep, Period>& rtime,
any_tuple what) {
if (whom) get_scheduler()->delayed_send(whom, rtime, what);
}
/**
* @brief Sends a message to @p whom that is delayed by @p rel_time.
* @param whom Receiver of the message.
......@@ -269,22 +313,6 @@ inline void delayed_send(const channel_ptr& whom,
}
}
/**
* @brief Sends a reply message that is delayed by @p rel_time.
* @param rtime Relative time duration to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param what Message content as a tuple.
* @see delayed_send()
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_reply_tuple(const std::chrono::duration<Rep, Period>& rtime,
any_tuple what) {
get_scheduler()->delayed_reply(self->last_sender(),
rtime,
self->get_response_id(),
std::move(what));
}
/**
* @brief Sends a reply message that is delayed by @p rel_time.
* @param rtime Relative time duration to delay the message in
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/send.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/singletons.hpp"
namespace cppa {
void delayed_send_tuple(const channel_ptr& to,
const util::duration& rel_time,
any_tuple data) {
if (to) get_scheduler()->delayed_send(to, rel_time, std::move(data));
}
void delayed_reply_tuple(const util::duration& rel_time,
message_id mid,
any_tuple data) {
auto& receiver = self->last_sender();
if (receiver) get_scheduler()->delayed_reply(receiver,
rel_time,
mid,
std::move(data));
}
void delayed_reply_tuple(const util::duration& rel_time, any_tuple data) {
delayed_reply_tuple(rel_time, self->get_response_id(), std::move(data));
}
} // namespace cppa
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