1 #pragma once 2 3 #include <jsi/jsi.h> 4 #include <memory> 5 #include "ErrorHandler.h" 6 #include "RuntimeDecorator.h" 7 #include "Scheduler.h" 8 9 namespace reanimated { 10 11 using namespace facebook; 12 13 /** 14 A class that manages a jsi::Runtime apart from the React-JS runtime. 15 */ 16 class RuntimeManager { 17 public: 18 RuntimeManager( 19 std::shared_ptr<jsi::Runtime> runtime, 20 std::shared_ptr<ErrorHandler> errorHandler, 21 std::shared_ptr<Scheduler> scheduler, 22 RuntimeType runtimeType = RuntimeType::Worklet) runtime(runtime)23 : runtime(runtime), errorHandler(errorHandler), scheduler(scheduler) { 24 RuntimeDecorator::registerRuntime(this->runtime.get(), runtimeType); 25 } 26 27 /** 28 Holds the jsi::Runtime this RuntimeManager is managing. 29 */ 30 std::shared_ptr<jsi::Runtime> runtime; 31 /** 32 Holds the error handler that will be invoked when any kind of error occurs. 33 */ 34 std::shared_ptr<ErrorHandler> errorHandler; 35 /** 36 Holds the Scheduler that is responsible for scheduling work on the UI- or 37 React-JS Thread. 38 */ 39 std::shared_ptr<Scheduler> scheduler; 40 }; 41 42 } // namespace reanimated 43