@@ -28,16 +28,23 @@ namespace py = pybind11;
2828namespace taskr
2929{
3030
31+ /* *
32+ * Vector to keep track which cpp functions to register
33+ */
3134std::vector<FunctionRegistration> &get_registry ()
3235{
3336 static std::vector<FunctionRegistration> reg;
3437 return reg;
3538}
3639
40+ /* *
41+ * Function to store the cpp function with a given naming
42+ */
3743void register_function (const std::string &name, function_t fc) { get_registry ().push_back ({name, fc}); }
3844
39- // TODO: add all methods of all classes
40-
45+ /* *
46+ * Pybind11 module for binding taskr stuff
47+ */
4148PYBIND11_MODULE (taskr, m)
4249{
4350 m.doc () = " pybind11 plugin for TaskR" ;
@@ -66,25 +73,36 @@ PYBIND11_MODULE(taskr, m)
6673 // TaskR's Runtime class
6774 py::class_<Runtime>(m, " Runtime" )
6875 .def (" setTaskCallbackHandler" , &Runtime::setTaskCallbackHandler)
76+ .def (" setServiceWorkerCallbackHandler" , &Runtime::setServiceWorkerCallbackHandler)
77+ .def (" setTaskWorkerCallbackHandler" , &Runtime::setTaskWorkerCallbackHandler)
6978 .def (" initialize" , &Runtime::initialize)
7079 .def (" addTask" , &Runtime::addTask, py::keep_alive<1 , 2 >()) // keep_alive as the task should be alive until runtime's destructor
7180 .def (" resumeTask" , &Runtime::resumeTask)
7281 .def (" run" , &Runtime::run, py::call_guard<py::gil_scoped_release>())
7382 .def (" await_" , &Runtime::await, py::call_guard<py::gil_scoped_release>()) // Release GIL is important otherwise non-finished tasks are getting blocked
74- .def (" finalize" , &Runtime::finalize);
83+ .def (" finalize" , &Runtime::finalize)
84+ .def (" setFinishedTask" , &Runtime::setFinishedTask)
85+ .def (" addService" , &Runtime::addService);
7586
7687 // TaskR's Function class
7788 py::class_<Function>(m, " Function" ).def (py::init<const function_t >());
7889
7990 // TaskR's Task class
8091 py::class_<Task>(m, " Task" )
92+ .def (py::init<Function *, const workerId_t>(), py::arg (" fc" ), py::arg (" workerAffinity" ) = -1 )
8193 .def (py::init<const label_t , Function *, const workerId_t>(), py::arg (" label" ), py::arg (" fc" ), py::arg (" workerAffinity" ) = -1 )
8294 .def (" getLabel" , &Task::getLabel)
8395 .def (" setLabel" , &Task::setLabel)
8496 .def (" getWorkerAffinity" , &Task::getWorkerAffinity)
8597 .def (" setWorkerAffinity" , &Task::setWorkerAffinity)
8698 .def (" addDependency" , &Task::addDependency)
99+ .def (" getDependencyCount" , &Task::getDependencyCount)
100+ .def (" incrementDependencyCount" , &Task::incrementDependencyCount)
101+ .def (" decrementDependencyCount" , &Task::decrementDependencyCount)
102+ .def (" addOutputDependency" , &Task::addOutputDependency)
103+ .def (" getOutputDependencies" , &Task::getOutputDependencies)
87104 .def (" addPendingOperation" , &Task::addPendingOperation)
105+ .def (" getPendingOperations" , &Task::getPendingOperations)
88106 .def (" suspend" , &Task::suspend, py::call_guard<py::gil_scoped_release>());
89107
90108 py::enum_<Task::callback_t >(m, " TaskCallback" )
@@ -95,7 +113,7 @@ PYBIND11_MODULE(taskr, m)
95113 .export_values ();
96114
97115 // TaskR's Mutex class
98- py::class_<Mutex>(m, " Mutex" ).def (py::init<>()).def (" lock" , &Mutex::lock).def (" unlock" , &Mutex::unlock);
116+ py::class_<Mutex>(m, " Mutex" ).def (py::init<>()).def (" lock" , &Mutex::lock).def (" unlock" , &Mutex::unlock). def ( " ownsLock " , &Mutex::ownsLock). def ( " trylock " , &Mutex::trylock) ;
99117
100118 // TaskR's ConditionVariable class
101119 py::class_<ConditionVariable>(m, " ConditionVariable" )
0 commit comments