@@ -30,27 +30,9 @@ static inline void ReplaceAllW(std::wstring &str, const std::wstring& from, cons
3030 }
3131}
3232
33- void AntispamAsyncWorker (Antispam *antispam)
34- {
35- using namespace std ::chrono_literals;
36- LoginDatabase.ThreadStart ();
37- LogsDatabase.ThreadStart ();
38- auto prevNow = Clock::now ();
39- while (!sWorld .IsStopped ())
40- {
41- auto currNow = Clock::now ();
42- auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(currNow - prevNow).count ();
43- antispam->processMessages (diff);
44- prevNow = currNow;
45- std::this_thread::sleep_for (50ms);
46- }
47- LogsDatabase.ThreadEnd ();
48- LoginDatabase.ThreadEnd ();
49- }
50-
5133Antispam::Antispam ()
5234 : m_enabled(false ), m_restrictionLevel(0 ), m_originalNormalizeMask(0 ), m_fullyNormalizeMask(0 ),
53- m_threshold(0 ), m_mutetime(0 ), m_chatMask(0 ), m_worker(), m_banEnabled(false ), m_detectThreshold(3 ),
35+ m_threshold(0 ), m_mutetime(0 ), m_chatMask(0 ), m_worker(nullptr ), m_banEnabled(false ), m_detectThreshold(3 ),
5436 m_messageBlockSize(5 ), m_updateTimer(60000 ), m_messageRepeatCount(5 ), m_frequencyCount(5 .0f ), m_frequencyTime(6 .0f ),
5537 m_mergeAllWhispers(false )
5638{
@@ -169,14 +151,14 @@ void Antispam::loadConfig()
169151 m_frequencyCount = sWorld .getConfig (CONFIG_UINT32_AC_ANTISPAM_FREQUENCY_COUNT);
170152 m_frequencyCoeff = m_frequencyCount / m_frequencyTime;
171153
172- if (!m_worker. joinable () )
173- m_worker = std::thread (AntispamAsyncWorker, this );
154+ if (!m_worker)
155+ m_worker = new ACE_Based::Thread ( new AntispamAsyncWorker ( this ) );
174156}
175157
176158void Antispam::PushToMessageQueue (MessageBlock const & messageBlock)
177159{
178160#ifdef USE_STANDARD_MALLOC
179- std::lock_guard<std::mutex> lock (m_messageMutex);
161+ ACE_Guard<ACE_Thread_Mutex> guard (m_messageMutex);
180162 m_messageQueue.push (messageBlock);
181163#else
182164 m_messageQueue.push (messageBlock);
@@ -186,7 +168,7 @@ void Antispam::PushToMessageQueue(MessageBlock const& messageBlock)
186168bool Antispam::TryPopFromMessageQueue (MessageBlock& messageBlock)
187169{
188170#ifdef USE_STANDARD_MALLOC
189- std::lock_guard<std::mutex> lock (m_messageMutex);
171+ ACE_Guard<ACE_Thread_Mutex> guard (m_messageMutex);
190172 if (m_messageQueue.empty ())
191173 return false ;
192174 messageBlock = m_messageQueue.front ();
0 commit comments