Skip to content

Commit a9707cb

Browse files
committed
FIX | quiche upload transfer counting & openssl shutdown error & openssl quic shutdown error & tcp shutdown error & http2 read flush error & add log service names
1 parent ad972cb commit a9707cb

62 files changed

Lines changed: 2431 additions & 1875 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int main () {
151151
{"verify_peer", false},
152152
{"alpn", true},
153153
{"method", "GET"}
154-
})));
154+
}));
155155

156156
if (!fetch.ok()) {
157157
co_return resp.json ({{"error", true}, {"message", "fetch failed"}}).unwrap();

handlers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// });
5353
//
5454
// router.GET("/", [&folder] (http::req &req, http::resp &resp) -> manapi::future<> {
55-
// co_return resp.file(manapi::filesystem::path::join(folder, "index.html")).unwrap();
55+
// co_return resp.file(manapi::fs::path::join(folder, "index.html")).unwrap();
5656
// });
5757
//
5858
//
@@ -141,7 +141,7 @@
141141
//
142142
// std::size_t sss = 0;
143143
// co_return resp.callback_stream([&sss, &resp, &req] (manapi::net::http::response::resp_stream_cb cb) -> manapi::future<> {
144-
// auto fs = manapi::filesystem::fstream::create ("/home/Timur/Downloads/VideoDownloader/ufa.mp4").unwrap();
144+
// auto fs = manapi::fs::fstream::create ("/home/Timur/Downloads/VideoDownloader/ufa.mp4").unwrap();
145145
// auto rhs = co_await fs.open(manapi::ev::FS_O_RDONLY);
146146
// rhs.unwrap();
147147
// (co_await req.callback_async([&sss, cb = std::move(cb), fs] (manapi::slice_view buffs, bool fin) mutable
@@ -291,7 +291,7 @@
291291
// auto cancellation = manapi::ctoken::unit(req.cancellation());
292292
// cancellation.timeout(5000);
293293
// cancellation.ask_cancel_callback();
294-
// auto file = manapi::filesystem::fstream::create ("/home/Timur/Downloads/VideoDownloader/ufa.mp4",
294+
// auto file = manapi::fs::fstream::create ("/home/Timur/Downloads/VideoDownloader/ufa.mp4",
295295
// cancellation).unwrap();
296296
// co_await file.open (manapi::ev::FS_O_RDONLY|manapi::ev::FS_O_NONBLOCK);
297297
// if (!file.is_open()) {

include/ManapiDebug.hpp

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,58 @@ namespace manapi::debug {
2222
LOG_TRACE_HARD
2323
} trace_level;
2424

25-
extern int log_trace_enabled;
25+
void logit(log_level type, const char* file, int line, const char *name, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
2626

27-
void logit(log_level type, const char* file, int line, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
27+
void logit(log_level type, const char* file, int line, const char *name, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
2828

29-
void logit(log_level type, const char* file, int line, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
29+
void flogit(log_level type, const char* file, const char *func, int line, const char *name, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
3030

31-
void flogit(log_level type, const char* file, const char *func, int line, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
31+
void flogit(log_level type, const char* file, const char *func, int line, const char *name, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
3232

33-
void flogit(log_level type, const char* file, const char *func, int line, int level, const char* fmt, ...) MANAPIHTTP_NOEXCEPT;
33+
#ifndef LOGNAME
34+
# define LOGNAME "manapihttp"
35+
#endif
3436

3537
// Convenience macros
36-
#define manapi_log_trace(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
37-
#define manapi_log_trace_hard(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, manapi::debug::LOG_TRACE_HARD, __VA_ARGS__)
38-
#define manapi_log_debug(...) manapi::debug::logit(manapi::debug::LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
39-
#define manapi_log_info(...) manapi::debug::logit(manapi::debug::LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
40-
#define manapi_log_warn(...) manapi::debug::logit(manapi::debug::LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
41-
#define manapi_log_error(...) manapi::debug::logit(manapi::debug::LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
42-
#define manapi_log_fatal(...) manapi::debug::logit(manapi::debug::LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
38+
#define manapi_log_trace(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
39+
#define manapi_log_trace_hard(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, LOGNAME, manapi::debug::LOG_TRACE_HARD, __VA_ARGS__)
40+
#define manapi_log_debug(...) manapi::debug::logit(manapi::debug::LOG_DEBUG, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
41+
#define manapi_log_info(...) manapi::debug::logit(manapi::debug::LOG_INFO, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
42+
#define manapi_log_warn(...) manapi::debug::logit(manapi::debug::LOG_WARN, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
43+
#define manapi_log_error(...) manapi::debug::logit(manapi::debug::LOG_ERROR, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
44+
#define manapi_log_fatal(...) manapi::debug::logit(manapi::debug::LOG_FATAL, __FILE__, __LINE__, LOGNAME, __VA_ARGS__)
45+
#define manapi_log_trace2(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
46+
#define manapi_log_trace_hard2(...) manapi::debug::logit(manapi::debug::LOG_TRACE, __FILE__, __LINE__, manapi::debug::LOG_TRACE_HARD, __VA_ARGS__)
47+
#define manapi_log_debug2(...) manapi::debug::logit(manapi::debug::LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
48+
#define manapi_log_info2(...) manapi::debug::logit(manapi::debug::LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
49+
#define manapi_log_warn2(...) manapi::debug::logit(manapi::debug::LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
50+
#define manapi_log_error2(...) manapi::debug::logit(manapi::debug::LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
51+
#define manapi_log_fatal2(...) manapi::debug::logit(manapi::debug::LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
4352
#ifdef _MSC_VER
44-
# define manapi_log_ferror(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
45-
# define manapi_log_ftrace(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
46-
# define manapi_log_finfo(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
47-
# define manapi_log_fwarn(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
48-
# define manapi_log_fdebug(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
49-
# define manapi_log_ffatal(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
53+
# define manapi_log_ferror(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
54+
# define manapi_log_ftrace(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
55+
# define manapi_log_finfo(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
56+
# define manapi_log_fwarn(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
57+
# define manapi_log_fdebug(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
58+
# define manapi_log_ffatal(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __FUNCTION__, __LINE__, LOGNAME,__VA_ARGS__)
59+
# define manapi_log_ferror2(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
60+
# define manapi_log_ftrace2(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
61+
# define manapi_log_finfo2(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
62+
# define manapi_log_fwarn2(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
63+
# define manapi_log_fdebug2(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
64+
# define manapi_log_ffatal2(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __FUNCTION__, __LINE__,__VA_ARGS__)
5065
#else
51-
# define manapi_log_ferror(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __func__, __LINE__, __VA_ARGS__)
52-
# define manapi_log_ftrace(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __func__, __LINE__, __VA_ARGS__)
53-
# define manapi_log_finfo(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __func__, __LINE__, __VA_ARGS__)
54-
# define manapi_log_fwarn(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __func__, __LINE__, __VA_ARGS__)
55-
# define manapi_log_fdebug(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __func__, __LINE__, __VA_ARGS__)
56-
# define manapi_log_ffatal(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __func__, __LINE__, __VA_ARGS__)
66+
# define manapi_log_ferror(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
67+
# define manapi_log_ftrace(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
68+
# define manapi_log_finfo(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
69+
# define manapi_log_fwarn(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
70+
# define manapi_log_fdebug(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
71+
# define manapi_log_ffatal(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __func__, __LINE__, LOGNAME,__VA_ARGS__)
72+
# define manapi_log_ferror2(...) manapi::debug::flogit(manapi::debug::LOG_ERROR, __FILE__, __func__, __LINE__,__VA_ARGS__)
73+
# define manapi_log_ftrace2(...) manapi::debug::flogit(manapi::debug::LOG_TRACE, __FILE__, __func__, __LINE__,__VA_ARGS__)
74+
# define manapi_log_finfo2(...) manapi::debug::flogit(manapi::debug::LOG_INFO, __FILE__, __func__, __LINE__,__VA_ARGS__)
75+
# define manapi_log_fwarn2(...) manapi::debug::flogit(manapi::debug::LOG_WARN, __FILE__, __func__, __LINE__,__VA_ARGS__)
76+
# define manapi_log_fdebug2(...) manapi::debug::flogit(manapi::debug::LOG_DEBUG, __FILE__, __func__, __LINE__,__VA_ARGS__)
77+
# define manapi_log_ffatal2(...) manapi::debug::flogit(manapi::debug::LOG_FATAL, __FILE__, __func__, __LINE__,__VA_ARGS__)
5778
#endif
5879
}

include/ManapiEventLoop.hpp

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace manapi::ev {
4141

4242
typedef std::move_only_function<void(const ev::shared_tcp &, ssize_t nread, const uv_buf_t *buf)> tcp_connection_cb;
4343

44-
typedef std::move_only_function<void(const ev::shared_udp &, ssize_t nread, const uv_buf_t *buf, const sockaddr *addr, unsigned flags)> udp_cb;
44+
typedef std::move_only_function<void(const ev::shared_udp &, ssize_t nread, const uv_buf_t *buf, const sockaddr *addr, unsigned m_flags)> udp_cb;
4545

4646
typedef std::move_only_function<void(const ev::shared_udp_send &, int status)> udp_send_cb;
4747

@@ -220,7 +220,7 @@ namespace manapi {
220220
* @return
221221
* @throws manapi::exception with ERR_INTERNAL code
222222
*/
223-
manapi::ev::status_or<std::shared_ptr<ev::getnameinfo>> create_watcher_getnameinfo (const struct sockaddr *addr, int flags, ev::getnameinfo_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
223+
manapi::ev::status_or<std::shared_ptr<ev::getnameinfo>> create_watcher_getnameinfo (const struct sockaddr *addr, int m_flags, ev::getnameinfo_cb callback, manapi::ctoken token = nullptr) MANAPIHTTP_NOEXCEPT;
224224

225225
/**
226226
*
@@ -322,10 +322,12 @@ namespace manapi {
322322

323323
manapi::ev::status start () MANAPIHTTP_NOEXCEPT;
324324

325+
void breakit () MANAPIHTTP_NOEXCEPT;
326+
325327
/**
326328
* Run Event Loop
327329
* @param mode Run Mode
328-
* @return AbortedError when event loop is interrupted or stopped (you must to finish the current context),
330+
* @return AbortedError when event loop is m_interrupted or stopped (you must to finish the current context),
329331
* AlreadExists when event loop already exists,
330332
* returns Ok in other cases
331333
*/
@@ -348,72 +350,54 @@ namespace manapi {
348350
#endif
349351

350352
void custom_watcher_callback_async (const std::shared_ptr<ev::async> &w);
351-
private:
352-
#if MANAPIHTTP_CURL_DEPENDENCY
353-
void wait_all_ (bool shutdown) MANAPIHTTP_NOEXCEPT;
354353

355-
void timerpool_init_ (std::shared_ptr<manapi::timerpool> tp);
354+
void timerpool_init (std::shared_ptr<manapi::timerpool> tp);
356355

356+
void wait_all (bool shutdown) MANAPIHTTP_NOEXCEPT;
357+
private:
358+
#if MANAPIHTTP_CURL_DEPENDENCY
357359
static manapi::ev::status_or<std::shared_ptr<ev::io>> handle_curl_watcher_gen(event_loop *data, socket_t fd) MANAPIHTTP_NOEXCEPT;
358360

359361
static socket_t handle_curl_open_socket (void *cbp, int socktype, void *addr);
360362

361-
//static_assert(ev::READ == CURL_POLL_IN && ev::WRITE == CURL_POLL_OUT, "need for review");
362-
363363
static int handle_curl_socket (void *curl, socket_t fd, int revents, void *userp, void *);
364364

365365
static int handle_curl_close_socket (void *cbp, socket_t socket);
366-
367-
void handle_curl_watcher_data(std::unique_ptr<ev::internal::adding_curl_data_t> data);
368366
#endif
369-
future<std::optional<manapi::timer>> template_cmd_timer_ (int flag, size_t data, std::move_only_function<manapi::future<>(manapi::timer t)> cb_async, std::move_only_function<void(manapi::timer t)> cb_sync);
370-
371-
static std::atomic<bool> interrupted;
372-
373-
static std::map <size_t, std::shared_ptr<event_loop>> events;
374-
375-
static std::mutex stop_mx;
376-
377-
manapi::ev::status register_ () MANAPIHTTP_NOEXCEPT;
378-
379-
void unregister_ () MANAPIHTTP_NOEXCEPT;
380-
381-
manapi::future<> _call_on_finish_cb ();
382-
383-
void free_on_finish_cb_ ();
367+
static std::atomic<bool> m_interrupted;
384368

385-
void try_tasks_ (const ev::shared_idle &w);
369+
static std::map <size_t, std::shared_ptr<event_loop>> m_events;
386370

387-
int flags;
371+
static std::mutex m_stop_mx;
388372

389-
std::atomic<int> interrupted_;
373+
int m_flags;
390374

391-
std::shared_ptr<threadpool> etaskpool_;
375+
std::shared_ptr<threadpool> m_etaskpool;
392376

393-
std::unique_ptr<uv_loop_t> loop_;
377+
std::unique_ptr<uv_loop_t> m_loop;
394378

395-
std::shared_ptr<threadpool> taskpool_;
379+
std::shared_ptr<threadpool> m_taskpool;
396380

397-
std::map <size_t, std::pair<int, std::move_only_function<manapi::future<void>()>>> map_finish_cb;
381+
std::map <size_t, std::pair<int, std::move_only_function<manapi::future<void>()>>> m_map_finish_cb;
398382

399-
std::map <size_t, std::move_only_function<void()>> map_clean_up_cb;
383+
std::map <size_t, std::move_only_function<void()>> m_map_clean_up_cb;
400384

401-
std::shared_ptr<ev::async> interrupted_watcher_;
385+
std::shared_ptr<ev::async> m_interrupted_watcher;
402386

403387
#if MANAPIHTTP_CURL_DEPENDENCY
404-
std::unique_ptr<ev::internal::curl_watcher_t> curl_watcher;
388+
std::unique_ptr<ev::internal::curl_watcher_t> m_curl_watcher;
405389
#endif
406390

407-
std::unique_ptr<ev::internal::custom_callback_t> callback_watcher_{};
391+
std::unique_ptr<ev::internal::custom_callback_t> m_callback_watcher{};
408392

409-
std::shared_ptr<ev::idle> idle_tasks_;
393+
std::shared_ptr<ev::idle> m_idle_tasks;
410394

411-
std::shared_ptr<ev::prepare> prepare_tasks_;
395+
std::shared_ptr<ev::prepare> m_prepare_tasks;
412396

413-
std::shared_ptr<manapi::logger> logger_;
397+
std::shared_ptr<manapi::logger> m_logger;
414398

415-
std::move_only_function<void()> custom_event_loop_;
399+
std::move_only_function<void()> m_custom_event_loop;
416400

417-
std::size_t deps_;
401+
std::size_t m_deps;
418402
};
419403
}

include/ManapiEventStructures.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ namespace manapi::ev {
9999
EV_ASYNC
100100
};
101101
enum flags {
102-
READ = UV_READABLE,
103-
WRITE = UV_WRITABLE,
104-
DISCONNECT = UV_DISCONNECT,
105-
PRIORITIZED = UV_PRIORITIZED
102+
READ = 1<<0,
103+
WRITE = 1<<1,
104+
DISCONNECT = 1<<2,
105+
PRIORITIZED = 1<<3
106106
};
107+
static_assert((int)flags::READ == (int)UV_READABLE && (int)flags::WRITE == (int)UV_WRITABLE
108+
&& (int)flags::DISCONNECT == (int)UV_DISCONNECT && (int)flags::PRIORITIZED == (int)UV_PRIORITIZED);
107109
enum fs_o_flags {
108110
FS_O_APPEND = UV_FS_O_APPEND,
109111
FS_O_CREAT = UV_FS_O_CREAT,

include/ManapiInitTools.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ namespace manapi::init_tools {
3636
* Enable Log Trace
3737
*/
3838
void log_trace_init (manapi::debug::trace_level lvl);
39+
40+
/**
41+
* Enable Log
42+
*/
43+
void log_name_enable (const char *name, bool enable);
3944
}
4045

4146
namespace manapi::clear_tools {

include/ManapiThreadPool.hpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace manapi {
1515
class threadpool {
1616
public:
17-
threadpool(std::shared_ptr<manapi::logger> logger) : logger_(std::move(logger)) {}
17+
threadpool(std::shared_ptr<manapi::logger> logger) : m_logger(std::move(logger)) {}
1818

1919
virtual ~threadpool() = default;
2020

@@ -31,10 +31,10 @@ namespace manapi {
3131
MANAPIHTTP_NODISCARD virtual std::size_t tasks_size () const MANAPIHTTP_NOEXCEPT = 0;
3232

3333
const std::shared_ptr<manapi::logger> &logger () MANAPIHTTP_NOEXCEPT {
34-
return this->logger_;
34+
return this->m_logger;
3535
}
3636
protected:
37-
std::shared_ptr<manapi::logger> logger_;
37+
std::shared_ptr<manapi::logger> m_logger;
3838
};
3939

4040
class mthreadpool : public threadpool {
@@ -65,33 +65,33 @@ namespace manapi {
6565

6666
MANAPIHTTP_NODISCARD std::size_t tasks_size() const MANAPIHTTP_NOEXCEPT override;
6767
private:
68-
// this vector contains all threads for this thread pool
69-
std::vector <std::thread> threads;
68+
// the function that the thread runs. Execute run() function
69+
static void *worker(void *arg, ssize_t index);
7070

71-
std::mutex m;
71+
void run(ssize_t index);
7272

73-
std::condition_variable cv;
73+
int get_task(ssize_t index, std::move_only_function<void()> *cb1, manapi::fixed_function<void()> *cb2);
74+
75+
// this vector contains all m_threads for this thread pool
76+
std::vector <std::thread> m_threads;
7477

75-
tasks_by_thread_t tasks_by_thread;
78+
std::mutex m_m;
7679

77-
// this vector of queue which contains tasks
78-
std::vector <std::move_only_function<void()>> tasks;
80+
std::condition_variable m_cv;
7981

80-
std::vector <manapi::fixed_function<void()>> tasks2;
82+
tasks_by_thread_t m_tasks_by_thread;
8183

82-
// queue mutex
83-
mutable std::mutex queue_mutex;
84+
// this vector of queue which contains m_tasks
85+
std::vector <std::move_only_function<void()>> m_tasks;
8486

85-
// the function that the thread runs. Execute run() function
86-
static void *worker(void *arg, ssize_t index);
87-
88-
void run(ssize_t index);
87+
std::vector <manapi::fixed_function<void()>> m_tasks2;
8988

90-
int get_task(ssize_t index, std::move_only_function<void()> *cb1, manapi::fixed_function<void()> *cb2);
89+
// queue mutex
90+
mutable std::mutex m_queue_mutex;
9191

92-
std::atomic<int> flags;
92+
std::atomic<int> m_flags;
9393

94-
ssize_t threadnum;
94+
ssize_t m_threadnum;
9595
};
9696

9797
class ethreadpool : public threadpool {
@@ -118,12 +118,12 @@ namespace manapi {
118118

119119
void join () MANAPIHTTP_NOEXCEPT override;
120120
private:
121-
int flags_;
121+
int m_flags;
122122

123-
std::vector <std::move_only_function<void()>> tasks;
123+
std::vector <std::move_only_function<void()>> m_tasks;
124124

125-
std::vector <manapi::fixed_function<void()>> tasks2;
125+
std::vector <manapi::fixed_function<void()>> m_tasks2;
126126

127-
std::move_only_function<void()> ontask_;
127+
std::move_only_function<void()> m_ontask;
128128
};
129129
}

0 commit comments

Comments
 (0)