@@ -23,29 +23,15 @@ namespace Babylon
2323 // copyable callable if necessary.
2424 if constexpr (std::is_copy_constructible<CallableT>::value)
2525 {
26- if (m_cancellationSource.cancelled ())
27- {
28- m_shutdownQueue.push ([callable = std::move (callable)] {});
29- }
30- else
31- {
32- m_dispatcher.queue ([this , callable = std::move (callable)]() {
33- callable (m_env.value ());
34- });
35- }
26+ m_dispatcher.queue ([this , callable = std::move (callable)]() {
27+ callable (m_env.value ());
28+ });
3629 }
3730 else
3831 {
39- if (m_cancellationSource.cancelled ())
40- {
41- m_shutdownQueue.push ([callablePtr = std::make_shared<CallableT>(std::move (callable))] {});
42- }
43- else
44- {
45- m_dispatcher.queue ([this , callablePtr = std::make_shared<CallableT>(std::move (callable))]() {
46- (*callablePtr)(m_env.value ());
47- });
48- }
32+ m_dispatcher.queue ([this , callablePtr = std::make_shared<CallableT>(std::move (callable))]() {
33+ (*callablePtr)(m_env.value ());
34+ });
4935 }
5036 }
5137
@@ -55,17 +41,9 @@ namespace Babylon
5541
5642 private:
5743 std::optional<Napi::Env> m_env{};
58-
5944 std::optional<std::scoped_lock<std::mutex>> m_suspensionLock{};
60-
6145 arcana::cancellation_source m_cancellationSource{};
62-
63- using DispatcherT = arcana::manual_dispatcher<128 >;
64- DispatcherT m_dispatcher{};
65-
66- // Put the callables in a separate queue during shutdown to ensure the callables are destroyed on the right thread.
67- arcana::blocking_concurrent_queue<DispatcherT::callback_t > m_shutdownQueue{};
68-
46+ arcana::manual_dispatcher<128 > m_dispatcher{};
6947 std::thread m_thread{};
7048 };
7149}
0 commit comments