mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 21:51:09 +08:00
Convert task_spec to flatbuffers (#255)
* convert Ray to C++ * convert task_spec to flatbuffers * fix * it compiles * latest * tests are passing * task2 -> task * fix * fix * fix * fix * fix * linting * fix valgrind * upgrade flatbuffers * use debug mode for valgrind * fix naming and comments * downgrade flatbuffers * fix linting * reintroduce TaskSpec_free * rename TaskSpec -> TaskInfo * refactoring * linting
This commit is contained in:
committed by
Robert Nishihara
parent
65a8659f3d
commit
0b8d279ef2
@@ -0,0 +1,59 @@
|
||||
#ifndef EXAMPLE_TASK_H
|
||||
#define EXAMPLE_TASK_H
|
||||
|
||||
#include "task.h"
|
||||
|
||||
extern TaskBuilder *g_task_builder;
|
||||
|
||||
const int64_t arg_value_size = 1000;
|
||||
|
||||
static inline TaskSpec *example_task_spec_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
ObjectID arg_ids[],
|
||||
int64_t *task_spec_size) {
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
TaskSpec_start_construct(g_task_builder, NIL_ID, parent_task_id, 0,
|
||||
NIL_ACTOR_ID, 0, func_id, num_returns);
|
||||
for (int64_t i = 0; i < num_args; ++i) {
|
||||
ObjectID arg_id;
|
||||
if (arg_ids == NULL) {
|
||||
arg_id = globally_unique_id();
|
||||
} else {
|
||||
arg_id = arg_ids[i];
|
||||
}
|
||||
TaskSpec_args_add_ref(g_task_builder, arg_id);
|
||||
}
|
||||
return TaskSpec_finish_construct(g_task_builder, task_spec_size);
|
||||
}
|
||||
|
||||
static inline TaskSpec *example_task_spec(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int64_t *task_spec_size) {
|
||||
return example_task_spec_with_args(num_args, num_returns, NULL,
|
||||
task_spec_size);
|
||||
}
|
||||
|
||||
static inline Task *example_task_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state,
|
||||
ObjectID arg_ids[]) {
|
||||
int64_t task_spec_size;
|
||||
TaskSpec *spec = example_task_spec_with_args(num_args, num_returns, arg_ids,
|
||||
&task_spec_size);
|
||||
Task *instance = Task_alloc(spec, task_spec_size, task_state, NIL_ID);
|
||||
TaskSpec_free(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
static inline Task *example_task(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state) {
|
||||
int64_t task_spec_size;
|
||||
TaskSpec *spec = example_task_spec(num_args, num_returns, &task_spec_size);
|
||||
Task *instance = Task_alloc(spec, task_spec_size, task_state, NIL_ID);
|
||||
TaskSpec_free(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
#endif /* EXAMPLE_TASK_H */
|
||||
Reference in New Issue
Block a user