mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-07 04:32:18 +00:00
Implement cached thread pool
This commit is contained in:
@@ -121,24 +121,6 @@ int new_daemon_thread(thread_entry entry, void *arg) {
|
||||
return xpthread_create(&thread, &attr, entry, arg);
|
||||
}
|
||||
|
||||
int new_daemon_thread(void(*entry)()) {
|
||||
thread_entry proxy = [](void *entry) -> void * {
|
||||
reinterpret_cast<void(*)()>(entry)();
|
||||
return nullptr;
|
||||
};
|
||||
return new_daemon_thread(proxy, (void *) entry);
|
||||
}
|
||||
|
||||
int new_daemon_thread(std::function<void()> &&entry) {
|
||||
thread_entry proxy = [](void *fp) -> void * {
|
||||
auto fn = reinterpret_cast<std::function<void()>*>(fp);
|
||||
(*fn)();
|
||||
delete fn;
|
||||
return nullptr;
|
||||
};
|
||||
return new_daemon_thread(proxy, new std::function<void()>(std::move(entry)));
|
||||
}
|
||||
|
||||
static char *argv0;
|
||||
static size_t name_len;
|
||||
void init_argv0(int argc, char **argv) {
|
||||
|
||||
@@ -82,8 +82,6 @@ static inline int parse_int(std::string_view s) { return parse_int(s.data()); }
|
||||
|
||||
using thread_entry = void *(*)(void *);
|
||||
int new_daemon_thread(thread_entry entry, void *arg = nullptr);
|
||||
int new_daemon_thread(void(*entry)());
|
||||
int new_daemon_thread(std::function<void()> &&entry);
|
||||
|
||||
static inline bool str_contains(std::string_view s, std::string_view ss) {
|
||||
return s.find(ss) != std::string::npos;
|
||||
|
||||
Reference in New Issue
Block a user