2
3
4
5
13
14
20
21
22
26
27
31
32
33
36 std::unique_lock<std::mutex> lock(m_Mutex);
43
44
47 std::unique_lock<std::mutex> lock(m_Mutex);
54
55
56
59 if (m_Sign.load() != sign)
61 std::unique_lock<std::mutex> lock(m_Mutex);
63 m_Cond.wait(lock, [&]() {
return m_Sign.load() == sign; });
68
69
70 const int GetSign()
const {
return m_Sign.load(); }
75
76
80
81
85
86
#define SPICES_PROFILE_ZONE
ThreadInitCallback m_ThreadInitCallback
ThreadInitCallback.
EventLoop * GetNextLoop()
Get next thread EventLoop.
InetAddress m_ListenAddress
ListenAddress.
std::vector< EventLoop * > GetAllLoops()
Get all thread EventLoop.
int m_Next
Next EventLoop index.
semaphore m_IsThreadsPrepared
ThreadsPrepared condition.
void ThreadFunc(Thread<> *thread)
Thread Function.
EventLoopThreadPool(const InetAddress &listenAddress)
Constructor Function. Create Specific ThreadPool.
void Start(int initThreadSize=3, ThreadInitCallback cb=nullptr)
Start Run this thread pool.
std::vector< EventLoop * > m_Loops
All threads EventLoop collection.
const std::string & Name() const
Get ThreadPool Name.
virtual ~EventLoopThreadPool() override=default
Destructor Function.
ThreadPool of Multiple threading EventLoop.
static EventLoop *& GetInst(InetAddress *address=nullptr)
Get EventLoop Instance. @reutrn Returns EventLoop Instance.
Wrapper of Instance/Delete ThreadCache in thread.
void Loop()
Start Event Loop.
Wrapper of Poller and wakeup socket to acceptor(SubLoop).
This class is Wrapper of current socket address.
static bool SetThreadName(const std::string &name)
Set Thread name.
Thread Static Function Library.
std::mutex m_Mutex
Mutex of this semaphore.
std::atomic_int m_Sign
Sign of this semaphore.
semaphore(int initSign=0)
Constructor Function.
void Sign(int sign)
Sign this semaphore with specific value.
void Increase()
Increase this semaphore sign.
std::condition_variable m_Cond
condition variable of this semaphore.
void Wait(int sign)
Wait this semaphore until it owns equal sign with given.
virtual ~semaphore()=default
Destructor Function.
const int GetSign() const
Get this semaphore current sign.
std::semaphore Implementation.