-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] Split frozen<T> and message_queue<T>.
Signals don't use queues, but use frozen events. Split these two entities to reduce include burden.
- Loading branch information
Andrey Sibiryov
committed
Mar 25, 2015
1 parent
5a90c4a
commit 54ea0c9
Showing
5 changed files
with
82 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
Copyright (c) 2011-2015 Andrey Sibiryov <[email protected]> | ||
Copyright (c) 2011-2015 Other contributors as noted in the AUTHORS file. | ||
This file is part of Cocaine. | ||
Cocaine 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 3 of the License, or | ||
(at your option) any later version. | ||
Cocaine 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 this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef COCAINE_IO_FROZEN_EVENTS_HPP | ||
#define COCAINE_IO_FROZEN_EVENTS_HPP | ||
|
||
#include "cocaine/rpc/protocol.hpp" | ||
#include "cocaine/rpc/slot.hpp" | ||
|
||
#include <boost/mpl/lambda.hpp> | ||
#include <boost/mpl/transform.hpp> | ||
|
||
#include <boost/variant/variant.hpp> | ||
|
||
namespace cocaine { namespace io { | ||
|
||
namespace mpl = boost::mpl; | ||
|
||
// Frozen events | ||
|
||
template<class Event> | ||
struct frozen { | ||
typedef Event event_type; | ||
typedef typename basic_slot<event_type>::tuple_type tuple_type; | ||
|
||
frozen() = default; | ||
|
||
template<typename... Args> | ||
frozen(event_type, Args&&... args): | ||
tuple(std::forward<Args>(args)...) | ||
{ } | ||
|
||
// NOTE: If the message cannot be sent right away, then the message arguments are placed into a | ||
// temporary storage until the upstream is attached. | ||
tuple_type tuple; | ||
}; | ||
|
||
template<class Event, typename... Args> | ||
frozen<Event> | ||
make_frozen(Args&&... args) { | ||
return frozen<Event>(Event(), std::forward<Args>(args)...); | ||
} | ||
|
||
template<class Tag> | ||
struct make_frozen_over { | ||
typedef typename mpl::transform< | ||
typename messages<Tag>::type, | ||
typename mpl::lambda<frozen<mpl::_1>> | ||
>::type frozen_types; | ||
|
||
typedef typename boost::make_variant_over<frozen_types>::type type; | ||
}; | ||
|
||
}} // namespace cocaine::io | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters