mirror of
https://github.com/wassname/ray.git
synced 2026-07-10 20:01:45 +08:00
C++ worker API refactoring (#9053)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user