Files
ray/cpp/include/ray/api/actor_handle.h
T
2020-06-24 19:33:46 +08:00

53 lines
1.1 KiB
C++

#pragma once
#include "ray/core.h"
namespace ray {
namespace api {
#include <ray/api/generated/actor_funcs.generated.h>
/// A handle to an actor which can be used to invoke a remote actor method, with the
/// `Call` method.
/// \param ActorType The type of the concrete actor class.
/// Note, the `Call` method is defined in actor_call.generated.h.
template <typename ActorType>
class ActorHandle {
public:
ActorHandle();
ActorHandle(const ActorID &id);
/// Get a untyped ID of the actor
const ActorID &ID() const;
/// Include the `Call` methods for calling remote functions.
#include <ray/api/generated/actor_call.generated.h>
/// Make ActorHandle serializable
MSGPACK_DEFINE(id_);
private:
ActorID id_;
};
// ---------- implementation ----------
template <typename ActorType>
ActorHandle<ActorType>::ActorHandle() {}
template <typename ActorType>
ActorHandle<ActorType>::ActorHandle(const ActorID &id) {
id_ = id;
}
template <typename ActorType>
const ActorID &ActorHandle<ActorType>::ID() const {
return id_;
}
#include <ray/api/generated/actor_call_impl.generated.h>
} // namespace api
} // namespace ray