Skip to content

Commit

Permalink
[C++ API][Fix] support ray::Init without RayConfig (ray-project#17733)
Browse files Browse the repository at this point in the history
  • Loading branch information
SongGuyang authored Aug 12, 2021
1 parent ab53c5f commit 63f9ba2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cpp/example/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class Counter {
RAY_REMOTE(Counter::FactoryCreate, &Counter::Add);

int main(int argc, char **argv) {
/// configuration and initialization
ray::RayConfig config;
ray::Init(config);
/// initialization
ray::Init();

/// put and get object
auto object = ray::Put(100);
Expand Down
17 changes: 9 additions & 8 deletions cpp/src/ray/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@

namespace ray {

void Init(ray::RayConfig &config, int *argc, char ***argv) {
void Init(RayConfig &config, int *argc, char ***argv) {
ray::internal::ConfigInternal::Instance().Init(config, argc, argv);
Init();
}

void Init(ray::RayConfig &config) { Init(config, nullptr, nullptr); }

void Init() {
std::call_once(is_inited_, [] {
auto runtime = ray::internal::AbstractRayRuntime::DoInit();
ray::internal::RayRuntimeHolder::Instance().Init(runtime);
});
}

void Init(RayConfig &config) { Init(config, nullptr, nullptr); }

void Init() {
RayConfig config;
Init(config, nullptr, nullptr);
}

void Shutdown() { ray::internal::AbstractRayRuntime::DoShutdown(); }

} // namespace ray
} // namespace ray

0 comments on commit 63f9ba2

Please sign in to comment.