diff --git a/ext/native/thread/executor.cpp b/ext/native/thread/executor.cpp index 8c5d6cd097..197f9d7920 100644 --- a/ext/native/thread/executor.cpp +++ b/ext/native/thread/executor.cpp @@ -1,11 +1,16 @@ #include "thread/executor.h" #include +#include namespace threading { void SameThreadExecutor::Run(std::function func) { - func(); + func(); +} + +void NewThreadExecutor::Run(std::function func) { + std::thread(func).detach(); } } // namespace threading diff --git a/ext/native/thread/executor.h b/ext/native/thread/executor.h index 7a5b5286a1..6d6515920c 100644 --- a/ext/native/thread/executor.h +++ b/ext/native/thread/executor.h @@ -6,13 +6,18 @@ namespace threading { // Stuff that can execute other stuff, like threadpools, should inherit from this. class Executor { - public: - virtual void Run(std::function func) = 0; +public: + virtual void Run(std::function func) = 0; }; class SameThreadExecutor : public Executor { - public: - virtual void Run(std::function func); +public: + void Run(std::function func) override; +}; + +class NewThreadExecutor : public Executor { +public: + void Run(std::function func) override; }; } // namespace threading