Kurlyk
Toggle main menu visibility
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
8
namespace
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
() {
27
core::NetworkWorker::get_instance
().
stop
();
28
}
29
32
inline
void
process
() {
33
core::NetworkWorker::get_instance
().
process
();
34
}
35
38
inline
void
shutdown
() {
39
core::NetworkWorker::get_instance
().
shutdown
();
40
}
41
44
inline
void
add_error_handler
(
::kurlyk::core::NetworkWorker::ErrorHandler
handler) {
45
::kurlyk::core::NetworkWorker::get_instance
().
add_error_handler
(std::move(handler));
46
}
47
48
}
// namespace kurlyk
49
50
#endif
// _KURLYK_STARTUP_RUNTIME_HPP_INCLUDED
kurlyk::HttpRequestManager::get_instance
static HttpRequestManager & get_instance()
Get the singleton instance of HttpRequestManager.
Definition
HttpRequestManager.hpp:28
kurlyk::WebSocketManager::get_instance
static WebSocketManager & get_instance()
Get the singleton instance of WebSocketManager.
Definition
WebSocketManager.hpp:40
kurlyk::core::NetworkWorker::stop
void stop()
Stops the worker thread, ensuring all tasks are completed.
Definition
NetworkWorker.hpp:190
kurlyk::core::NetworkWorker::get_instance
static NetworkWorker & get_instance()
Get the singleton instance of NetworkWorker.
Definition
NetworkWorker.hpp:26
kurlyk::core::NetworkWorker::process
void process()
Processes all queued tasks and active HTTP and WebSocket requests.
Definition
NetworkWorker.hpp:116
kurlyk::core::NetworkWorker::add_error_handler
void add_error_handler(ErrorHandler handler)
Registers a callback for handling network errors.
Definition
NetworkWorker.hpp:33
kurlyk::core::NetworkWorker::shutdown
void shutdown()
Shuts down the worker, clearing all active requests and pending tasks.
Definition
NetworkWorker.hpp:214
kurlyk::core::NetworkWorker::ErrorHandler
std::function< void(const std::exception &, const char *, const char *, int, const char *)> ErrorHandler
Definition
NetworkWorker.hpp:22
kurlyk
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
kurlyk::init
void init(const bool use_async=true)
Initializes the Kurlyk library, setting up necessary managers and the network worker.
Definition
runtime.hpp:13
kurlyk::shutdown
void shutdown()
Shuts down all network operations, resetting the state of the network worker and clearing pending req...
Definition
runtime.hpp:38
kurlyk::add_error_handler
void add_error_handler(::kurlyk::core::NetworkWorker::ErrorHandler handler)
Registers a global error handler for the network worker.
Definition
runtime.hpp:44
kurlyk::deinit
void deinit()
Deinitializes the Kurlyk library, stopping async processing or cleaning up synchronous state.
Definition
runtime.hpp:26
kurlyk::process
void process()
Processes pending requests (used in synchronous mode).
Definition
runtime.hpp:32
include
kurlyk
startup
runtime.hpp
Generated by
1.17.0