#include <map>
#include <list>
#include <set>
+#include <mutex>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#include <jthread.hpp>
+#pragma GCC diagnostic pop
#include <ctime>
#include <cstdint>
UsersImpl(SettingsImpl * s, Store * store,
Tariffs * tariffs, Services & svcs,
const Admin& sysAdmin);
- virtual ~UsersImpl();
int FindByName(const std::string & login, UserPtr * user) override;
int FindByName(const std::string & login, ConstUserPtr * user) const override;
bool IsIPInIndex(uint32_t ip) const override;
bool IsIPInUse(uint32_t ip, const std::string & login, ConstUserPtr * user) const override;
- int OpenSearch() override;
+ unsigned int OpenSearch() override;
int SearchNext(int handler, UserPtr * user) override;
int SearchNext(int handler, UserImpl ** user);
int CloseSearch(int handler) override;
void DelFromIPIdx(uint32_t ip);
bool FindByIPIdx(uint32_t ip, user_iter & iter) const;
- int FindByNameNonLock(const std::string & login, user_iter * user);
- int FindByNameNonLock(const std::string & login, const_user_iter * user) const;
+ bool FindByNameNonLock(const std::string & login, user_iter * user);
+ bool FindByNameNonLock(const std::string & login, const_user_iter * user) const;
void RealDelUser();
void ProcessActions();
void AddUserIntoIndexes(user_iter user);
void DelUserFromIndexes(user_iter user);
- static void * Run(void *);
+ void Run(std::stop_token token);
void NewMinute(const struct tm & t);
void NewDay(const struct tm & t);
void DayResetTraff(const struct tm & t);
std::map<std::string, user_iter> loginIndex;
SettingsImpl * settings;
- Tariffs * tariffs;
+ Tariffs * m_tariffs;
Services & m_services;
- Store * store;
- const Admin& sysAdmin;
+ Store * m_store;
+ const Admin& m_sysAdmin;
Logger & WriteServLog;
- bool nonstop;
bool isRunning;
- mutable pthread_mutex_t mutex;
- pthread_t thread;
+ mutable std::mutex m_mutex;
+ std::jthread m_thread;
mutable unsigned int handle;
- mutable std::map<int, user_iter> searchDescriptors;
+ mutable std::map<unsigned int, user_iter> searchDescriptors;
std::set<NotifierBase<UserPtr>*> onAddNotifiers;
std::set<NotifierBase<UserPtr>*> onDelNotifiers;