mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-05 03:02:06 +00:00
Enhancements
Fix rule generation in Surge configs. Refactor log output for curl verbose logs. Optimize codes.
This commit is contained in:
37 files changed
+317
-260
No files matched your search
+17
-2
@@ -5,7 +5,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../handler/settings.h"
|
||||
#include "handler/settings.h"
|
||||
#include "defer.h"
|
||||
#include "lock.h"
|
||||
#include "logger.h"
|
||||
|
||||
std::string getTime(int type)
|
||||
@@ -38,7 +40,20 @@ std::string getTime(int type)
|
||||
static std::string get_thread_name()
|
||||
{
|
||||
static std::atomic_int counter = 0;
|
||||
thread_local static std::string name = "Thread-" + std::to_string(counter++);
|
||||
static std::map<std::thread::id, std::string> thread_names;
|
||||
static RWLock lock;
|
||||
std::thread::id id = std::this_thread::get_id();
|
||||
lock.readLock();
|
||||
if (thread_names.find(id) != thread_names.end())
|
||||
{
|
||||
defer(lock.readUnlock();)
|
||||
return thread_names[id];
|
||||
}
|
||||
lock.readUnlock();
|
||||
lock.writeLock();
|
||||
std::string name = "Thread-" + std::to_string(++counter);
|
||||
thread_names[id] = name;
|
||||
lock.writeUnlock();
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user