mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 03:37:20 +08:00
[cpp worker] support cluster mode and object Put/Get works (#9682)
This commit is contained in:
@@ -33,7 +33,7 @@ int main() {
|
||||
|
||||
/// put and get object
|
||||
auto obj = Ray::Put(123);
|
||||
auto getRsult = obj.Get();
|
||||
auto get_result = obj.Get();
|
||||
|
||||
/// general function remote call(args passed by value)
|
||||
auto r0 = Ray::Task(Return1).Remote();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
/// This is a complete example of writing a distributed program using the C ++ worker API.
|
||||
|
||||
/// including the header
|
||||
#include <ray/api.h>
|
||||
#include <ray/api/ray_config.h>
|
||||
#include <ray/util/logging.h>
|
||||
|
||||
/// using namespace
|
||||
using namespace ray::api;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RAY_LOG(INFO) << "Start cpp worker example";
|
||||
|
||||
/// initialization to cluster mode
|
||||
ray::api::RayConfig::GetInstance()->run_mode = RunMode::CLUSTER;
|
||||
/// Set redis ip to connect an existing ray cluster.
|
||||
/// ray::api::RayConfig::GetInstance()->redis_ip = "127.0.0.1";
|
||||
Ray::Init();
|
||||
|
||||
/// put and get object
|
||||
auto obj = Ray::Put(123);
|
||||
auto get_result = *(obj.Get());
|
||||
|
||||
RAY_LOG(INFO) << "Get result: " << get_result;
|
||||
Ray::Shutdown();
|
||||
}
|
||||
Reference in New Issue
Block a user