Sese Framework
2.3.0
A cross-platform framework
|
User load balancer, applicable to all platforms. More...
#include <UserBalanceLoader.h>
Classes | |
struct | SocketStatus |
Socket status. More... | |
Public Member Functions | |
~UserBalanceLoader () noexcept | |
void | setThreads (size_t th) noexcept |
void | setAddress (const net::IPAddress::Ptr &addr) noexcept |
void | setAcceptTimeout (uint32_t to) noexcept |
void | setDispatchTimeout (uint32_t to) noexcept |
bool | isStarted () const |
template<class SERVICE > | |
bool | init () noexcept |
template<class SERVICE > | |
bool | init (std::function< SERVICE *()> creator) noexcept |
void | start () noexcept |
Start the current loader and service. | |
void | stop () noexcept |
Stop the current loader and unload services. | |
void | dispatchSocket (socket_t sock, void *data) |
void | setOnDispatchedCallbackFunction (const std::function< void(int, sese::event::EventLoop *, void *)> &cb) |
Protected Member Functions | |
void | master () noexcept |
void | slave (sese::event::EventLoop *event_loop, std::queue< SocketStatus > *master_queue, std::queue< SocketStatus > *slave_queue, std::mutex *mutex) noexcept |
Protected Attributes | |
std::atomic_bool | _isStart {false} |
std::atomic_bool | _isStop {false} |
uint32_t | acceptTimeout = 100 |
uint32_t | dispatchTimeout = 100 |
size_t | threads {2} |
std::vector< sese::event::EventLoop * > | eventLoopVector |
std::vector< sese::Thread::Ptr > | threadVector |
sese::net::IPAddress::Ptr | address = sese::net::IPv4Address::localhost(8080) |
sese::net::Socket * | socket {nullptr} |
sese::service::MasterEventLoop * | masterEventLoop {nullptr} |
sese::Thread::Ptr | masterThread {nullptr} |
std::queue< SocketStatus > * | masterSocketQueueArray {nullptr} |
socket_t exchange queues | |
std::queue< SocketStatus > * | slaveSocketQueueArray {nullptr} |
std::mutex * | mutexArray {nullptr} |
std::function< void(int, sese::event::EventLoop *event_loop, void *)> | onDispatchedCallbackFunction |
User load balancer, applicable to all platforms.
|
noexcept |
References _isStart, _isStop, sese::net::Socket::close(), eventLoopVector, masterEventLoop, masterSocketQueueArray, slaveSocketQueueArray, socket, and stop().
void sese::service::UserBalanceLoader::dispatchSocket | ( | sese::socket_t | sock, |
void * | data ) |
Referenced by sese::iocp::v1::IOCPServer::postConnect().
|
noexcept |
Initialize loader resources
SERVICE | Service to be started |
References init().
Referenced by sese::iocp::v1::IOCPServer::init(), and init().
|
noexcept |
Initialize balancer resources
SERVICE | Service to be started |
creator | Service creation function, returns an instance pointer on success, otherwise should return nullptr |
References sese::net::Socket::IPv4, sese::net::Socket::IPv6, and sese::net::Socket::TCP.
|
inlinenodiscard |
|
protectednoexcept |
Referenced by start().
|
inlinenoexcept |
Set the timeout for the main listening thread
to | Timeout in milliseconds |
References acceptTimeout.
Referenced by sese::iocp::v1::IOCPServer::setAcceptTimeout().
|
inlinenoexcept |
Set the service startup address
addr | IP Address |
References address.
Referenced by sese::iocp::v1::IOCPServer::setAddress().
|
inlinenoexcept |
Set the dispatch timeout for worker threads
to | Timeout in milliseconds |
References dispatchTimeout.
Referenced by sese::iocp::v1::IOCPServer::setDispatchTimeout().
|
inline |
References onDispatchedCallbackFunction.
Referenced by sese::iocp::v1::IOCPServer::IOCPServer().
|
noexcept |
Set the number of threads used by the loader
th | Number of threads |
Referenced by sese::iocp::v1::IOCPServer::setThreads().
|
protectednoexcept |
Referenced by start().
|
noexcept |
Start the current loader and service.
References master(), and slave().
Referenced by sese::iocp::v1::IOCPServer::init().
|
noexcept |
Stop the current loader and unload services.
References sese::net::Socket::close().
Referenced by sese::iocp::v1::IOCPServer::shutdown(), and ~UserBalanceLoader().
|
protected |
Referenced by isStarted(), and ~UserBalanceLoader().
|
protected |
Referenced by ~UserBalanceLoader().
|
protected |
Referenced by setAcceptTimeout().
|
protected |
Referenced by setAddress().
|
protected |
Referenced by setDispatchTimeout().
|
protected |
Referenced by ~UserBalanceLoader().
|
protected |
Referenced by ~UserBalanceLoader().
|
protected |
socket_t exchange queues
Referenced by ~UserBalanceLoader().
|
protected |
|
protected |
|
protected |
Referenced by setOnDispatchedCallbackFunction().
|
protected |
Referenced by ~UserBalanceLoader().
|
protected |
Referenced by ~UserBalanceLoader().
|
protected |
|
protected |