#include <list>
#include <map>
#include <string>
+#include <mutex>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#include <jthread.hpp>
+#pragma GCC diagnostic pop
#include <cstdint>
-#include <pthread.h>
-
#define PROTOMAX (5)
namespace STG
void FreeRules();
bool ReadRules(bool test = false);
- static void * Run(void * data);
+ void Run(std::stop_token token);
void DeterminateDir(const RawPacket & packet,
int * dirU, // Direction for upload
UsersImpl * users;
- bool running;
bool stopped;
- pthread_mutex_t mutex;
- pthread_t thread;
+ std::mutex m_mutex;
+ std::jthread m_thread;
std::list<TRF_IP_BEFORE> ipBeforeNotifiers;
std::list<TRF_IP_AFTER> ipAfterNotifiers;
if (!oldValue)
return;
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TraffCounterImpl::DelUser, oldValue);
+EVENT_LOOP::instance().Enqueue(traffCnt, &TraffCounterImpl::DelUser, oldValue);
}
//-----------------------------------------------------------------------------
inline
if (!newValue)
return;
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TraffCounterImpl::AddUser, user);
+EVENT_LOOP::instance().Enqueue(traffCnt, &TraffCounterImpl::AddUser, user);
}
//-----------------------------------------------------------------------------
inline
void ADD_USER_NONIFIER::Notify(const UserImplPtr & user)
{
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TraffCounterImpl::SetUserNotifiers, user);
+EVENT_LOOP::instance().Enqueue(traffCnt, &TraffCounterImpl::SetUserNotifiers, user);
}
//-----------------------------------------------------------------------------
inline
void DEL_USER_NONIFIER::Notify(const UserImplPtr & user)
{
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TraffCounterImpl::UnSetUserNotifiers, user);
-EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TraffCounterImpl::DelUser, user->GetCurrIP());
+EVENT_LOOP::instance().Enqueue(traffCnt, &TraffCounterImpl::UnSetUserNotifiers, user);
+EVENT_LOOP::instance().Enqueue(traffCnt, &TraffCounterImpl::DelUser, user->GetCurrIP());
}
//-----------------------------------------------------------------------------
}