Kurlyk
Loading...
Searching...
No Matches
AutoInitializer.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _KURLYK_STARTUP_AUTO_INITIALIZER_HPP_INCLUDED
3#define _KURLYK_STARTUP_AUTO_INITIALIZER_HPP_INCLUDED
4
7
8namespace kurlyk::startup {
9
17 public:
20 auto &instance = core::NetworkWorker::get_instance();
21# if KURLYK_HTTP_SUPPORT
23 instance.register_manager(m_http);
24# endif
25# if KURLYK_WEBSOCKET_SUPPORT
27 instance.register_manager(m_ws);
28# endif
29 instance.start(KURLYK_AUTO_INIT_USE_ASYNC);
30 }
31
36
37 private:
38# if KURLYK_HTTP_SUPPORT
39 HttpRequestManager* m_http = nullptr;
40# endif
41# if KURLYK_WEBSOCKET_SUPPORT
42 WebSocketManager* m_ws = nullptr;
43# endif
44 };
45
47
48} // namespace kurlyk::startup
49
50#endif // _KURLYK_STARTUP_AUTO_INITIALIZER_HPP_INCLUDED
Manages and processes HTTP requests using a singleton pattern.
static HttpRequestManager & get_instance()
Get the singleton instance of HttpRequestManager.
Manages backend-specific WebSocket client instances and coordinates their lifecycle.
static WebSocketManager & get_instance()
Get the singleton instance of WebSocketManager.
void stop()
Stops the worker thread, ensuring all tasks are completed.
static NetworkWorker & get_instance()
Get the singleton instance of NetworkWorker.
Automatically registers and manages network task managers.
AutoInitializer()
Constructs and registers all available managers.
~AutoInitializer()
Stops the NetworkWorker before program termination.
#define KURLYK_AUTO_INIT_USE_ASYNC
Determines whether the NetworkWorker runs in a background thread during automatic initialization.
Definition kurlyk.hpp:20
AutoInitializer _kurlyk_auto_initializer