Kurlyk
Loading...
Searching...
No Matches
runtime.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _KURLYK_STARTUP_RUNTIME_HPP_INCLUDED
3#define _KURLYK_STARTUP_RUNTIME_HPP_INCLUDED
4
7
8namespace kurlyk {
9
13 inline void init(const bool use_async = true) {
14 auto &instance = core::NetworkWorker::get_instance();
15# if KURLYK_HTTP_SUPPORT
16 instance.register_manager(&HttpRequestManager::get_instance());
17# endif
18# if KURLYK_WEBSOCKET_SUPPORT
19 instance.register_manager(&WebSocketManager::get_instance());
20# endif
21 instance.start(use_async);
22 }
23
26 inline void deinit() {
28 }
29
35
41
47
48} // namespace kurlyk
49
50#endif // _KURLYK_STARTUP_RUNTIME_HPP_INCLUDED
static HttpRequestManager & get_instance()
Get the singleton instance of HttpRequestManager.
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.
void process()
Processes all queued tasks and active HTTP and WebSocket requests.
void add_error_handler(ErrorHandler handler)
Registers a callback for handling network errors.
void shutdown()
Shuts down the worker, clearing all active requests and pending tasks.
std::function< void(const std::exception &, const char *, const char *, int, const char *)> ErrorHandler
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
void init(const bool use_async=true)
Initializes the Kurlyk library, setting up necessary managers and the network worker.
Definition runtime.hpp:13
void shutdown()
Shuts down all network operations, resetting the state of the network worker and clearing pending req...
Definition runtime.hpp:38
void add_error_handler(::kurlyk::core::NetworkWorker::ErrorHandler handler)
Registers a global error handler for the network worker.
Definition runtime.hpp:44
void deinit()
Deinitializes the Kurlyk library, stopping the network worker and releasing resources.
Definition runtime.hpp:26
void process()
Processes pending requests (used in synchronous mode).
Definition runtime.hpp:32