[core] make actor self reference optional - again
- uses a different method of constructor selection that also works on Apple clang < 8.2.
This commit is contained in:
committed by
Ivo van Dongen
parent
2dd8ec8854
commit
68f470fdda
@@ -50,13 +50,18 @@ class Actor : public util::noncopyable {
|
||||
public:
|
||||
|
||||
// Enabled for Objects with a constructor taking ActorRef<Object> as the first parameter
|
||||
template <typename U = Object, class... Args,
|
||||
typename std::enable_if<std::is_constructible<U, ActorRef<Object>, Args...>::value>::type...>
|
||||
template <typename U = Object, class... Args, typename std::enable_if<std::is_constructible<U, ActorRef<U>, Args...>::value>::type * = nullptr>
|
||||
Actor(Scheduler& scheduler, Args&&... args_)
|
||||
: mailbox(std::make_shared<Mailbox>(scheduler)),
|
||||
object(self(), std::forward<Args>(args_)...) {
|
||||
}
|
||||
|
||||
// Enabled for plain Objects
|
||||
template<typename U = Object, class... Args, typename std::enable_if<!std::is_constructible<U, ActorRef<U>, Args...>::value>::type * = nullptr>
|
||||
Actor(Scheduler& scheduler, Args&& ... args_)
|
||||
: mailbox(std::make_shared<Mailbox>(scheduler)), object(std::forward<Args>(args_)...) {
|
||||
}
|
||||
|
||||
~Actor() {
|
||||
mailbox->close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user