5 #include <unordered_map>
6 #include <unordered_set>
14 using std::unique_ptr;
15 using std::unordered_map;
16 using std::unordered_set;
25 class ServerWorkerThreadPool;
31 template <
typename CLIENT,
typename GROUP>
101 return _clientKeySet;
112 auto client = it !=
clientKeyMap.end()?it->second:
nullptr;
113 if (client !=
nullptr) {
114 client->acquireReference();
143 auto group = it !=
groupKeyMap.end()?it->second:
nullptr;
144 if (group !=
nullptr) {
145 group->acquireReference();
173 if (client->getKey() != clientKey) {
215 if (group->getKey() != groupKey) {
Base class for network servers.
bool setClientKey(CLIENT *client, const string &clientKey)
sets a client identification key
unordered_map< string, CLIENT * > GroupKeyMap
CLIENT * getClientByKey(const string &clientKey)
retrieve a client by key, the client reference is acquired, must be released after usage
ClientKeyMap clientKeyMap
ReadWriteLock clientKeyListsReadWriteLock
ClientKeySet getClientKeySet()
get a copy of current client keys
ClientKeySet clientKeySet
virtual ~Server()
destructor
unordered_set< string > ClientKeySet
void setThreadPoolMaxElements(int maxElements)
Sets up max number of elements in worker thread pool queue.
void closeClient(CLIENT *client)
closes a client connection
void setIOThreadCount(int ioThreadCount)
Sets up the numbers of threads to handle IO and framing.
int workerThreadPoolMaxElements
void setWorkerThreadCount(int workerThreadCount)
Sets up the number of workers that handle requests in thread pool.
ReadWriteLock groupKeyListsReadWriteLock
bool setGroupKey(GROUP *group, const string &groupKey)
sets a group identification key
unordered_set< CLIENT * > ClientSet
GROUP * getGroupByKey(const string &groupKey)
retrieve a group by key, the group reference is acquired, must be released after usage
unordered_set< string > GroupKeySet
unordered_map< string, CLIENT * > ClientKeyMap
int workerThreadPoolCount
void closeGroup(GROUP *group)
closes a group connection
ClientKeySet getGroupKeySet()
get a copy of current group keys
Implementation for read/write lock.
void writeLock()
Locks for writing / exclusive lock.
void unlock()
Unlocks this read write lock.
void readLock()
Locks for reading / shared lock.
#define FORBID_CLASS_COPY(CLASS)