Commit 6fb94bd4 authored by Dominik Charousset's avatar Dominik Charousset

added command_dispatcher to singletons

parent e307aec7
...@@ -43,6 +43,8 @@ class msg_content; ...@@ -43,6 +43,8 @@ class msg_content;
namespace cppa { namespace network { class middleman; } } namespace cppa { namespace network { class middleman; } }
namespace cppa { namespace opencl { class command_dispatcher; } }
namespace cppa { namespace detail { namespace cppa { namespace detail {
class empty_tuple; class empty_tuple;
...@@ -80,6 +82,8 @@ class singleton_manager { ...@@ -80,6 +82,8 @@ class singleton_manager {
static decorated_names_map* get_decorated_names_map(); static decorated_names_map* get_decorated_names_map();
static opencl::command_dispatcher* get_command_dispatcher();
private: private:
/** /**
......
...@@ -32,14 +32,28 @@ ...@@ -32,14 +32,28 @@
#ifndef CPPA_OPENCL_COMMAND_DISPATCHER_HPP #ifndef CPPA_OPENCL_COMMAND_DISPATCHER_HPP
#define CPPA_OPENCL_COMMAND_DISPATCHER_HPP #define CPPA_OPENCL_COMMAND_DISPATCHER_HPP
#include "cppa/detail/singleton_mixin.hpp"
namespace cppa { namespace opencl { namespace cppa { namespace opencl {
#ifdef CPPA_OPENCL
class command_dispatcher { class command_dispatcher {
public:
static inline command_dispatcher* create_singleton() {
return new command_dispatcher;
}
inline void initialize() { }
inline void dispose() { delete this; }
inline void destroy() { delete this; }
}; };
#else // CPPA_OPENCL
class command_dispatcher : public detail::singleton_mixin<command_dispatcher> {
} // namespace cppa::opencl };
#endif // CPPA_OPENCL
} } // namespace cppa::opencl
#endif // CPPA_OPENCL_COMMAND_DISPATCHER_HPP #endif // CPPA_OPENCL_COMMAND_DISPATCHER_HPP
...@@ -49,12 +49,15 @@ ...@@ -49,12 +49,15 @@
#include "cppa/detail/thread_pool_scheduler.hpp" #include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/uniform_type_info_map.hpp" #include "cppa/detail/uniform_type_info_map.hpp"
#include "cppa/opencl/command_dispatcher.hpp"
namespace cppa { void shutdown() { detail::singleton_manager::shutdown(); } } namespace cppa { void shutdown() { detail::singleton_manager::shutdown(); } }
namespace cppa { namespace detail { namespace cppa { namespace detail {
namespace { namespace {
std::atomic<opencl::command_dispatcher*> s_command_dispatcher;
std::atomic<uniform_type_info_map*> s_uniform_type_info_map; std::atomic<uniform_type_info_map*> s_uniform_type_info_map;
std::atomic<decorated_names_map*> s_decorated_names_map; std::atomic<decorated_names_map*> s_decorated_names_map;
std::atomic<network::middleman*> s_middleman; std::atomic<network::middleman*> s_middleman;
...@@ -78,6 +81,7 @@ void singleton_manager::shutdown() { ...@@ -78,6 +81,7 @@ void singleton_manager::shutdown() {
destroy(s_middleman); destroy(s_middleman);
std::atomic_thread_fence(std::memory_order_seq_cst); std::atomic_thread_fence(std::memory_order_seq_cst);
// it's safe to delete all other singletons now // it's safe to delete all other singletons now
destroy(s_command_dispatcher);
destroy(s_actor_registry); destroy(s_actor_registry);
destroy(s_group_manager); destroy(s_group_manager);
destroy(s_empty_tuple); destroy(s_empty_tuple);
...@@ -86,6 +90,10 @@ void singleton_manager::shutdown() { ...@@ -86,6 +90,10 @@ void singleton_manager::shutdown() {
destroy(s_logger); destroy(s_logger);
} }
opencl::command_dispatcher* singleton_manager::get_command_dispatcher() {
return lazy_get(s_command_dispatcher);
}
actor_registry* singleton_manager::get_actor_registry() { actor_registry* singleton_manager::get_actor_registry() {
return lazy_get(s_actor_registry); return lazy_get(s_actor_registry);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment