Kurlyk
Loading...
Searching...
No Matches
AutoInitializer.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef KURLYK_HEADER_KURLYK_STARTUP_AUTO_INITIALIZER_HPP_INCLUDED
3#define KURLYK_HEADER_KURLYK_STARTUP_AUTO_INITIALIZER_HPP_INCLUDED
4
7
8namespace kurlyk {
9namespace startup {
10
18 public:
21 auto &instance = core::NetworkWorker::get_instance();
22# if KURLYK_HTTP_SUPPORT
24 instance.register_manager(m_http);
25# endif
26# if KURLYK_WEBSOCKET_SUPPORT
28 instance.register_manager(m_ws);
29# endif
30 instance.start(KURLYK_AUTO_INIT_USE_ASYNC);
31 }
32
37
38 private:
39# if KURLYK_HTTP_SUPPORT
40 HttpRequestManager* m_http = nullptr;
41# endif
42# if KURLYK_WEBSOCKET_SUPPORT
43 WebSocketManager* m_ws = nullptr;
44# endif
45 };
46
49 static AutoInitializer instance;
50 return instance;
51 }
52
56
57} // namespace startup
58} // namespace kurlyk
59
60#endif // KURLYK_HEADER_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 & get_auto_initializer()
Returns the process-wide automatic initializer.
static AutoInitializer & _kurlyk_auto_initializer
Convenience auto-init helper.
Primary namespace for the Kurlyk library, encompassing initialization, request management,...