GithubHelp home page GithubHelp logo

zlmediakit / zltoolkit Goto Github PK

View Code? Open in Web Editor NEW
1.9K 89.0 580.0 31.63 MB

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO

License: MIT License

C++ 79.33% Objective-C++ 0.39% CMake 15.20% Shell 0.22% C 4.86%
network threadpool ssl logger sql timer epoll ringbuffer

zltoolkit's Issues

Thread Synchronization Issues in Logging

Writing logs often happens concurrently in different threads, because when writing logs, new log files are created and old log files are deleted. When thread 1 is creating a new log file, and thread 2 is deleting an old log file at the same time, the program will crash. It is recommended that the author fix this bug.

写日志经常会在不同的线程同时进行,因为在写日志的时候会创建新日志文件和删除旧日志文件,当线程1在创建新日志文件的时候,而线程2同时删除旧日志文件,程序就会崩溃,建议作者修改此bug

TRANS_BY_GITHUB_AI_ASSISTANT

Which network model does this network library use?

Could you please tell me if this network library is based on an event-driven IO network model similar to muduo, which is based on Reactor?

请问大佬该网络库是那种类似于muduo一样的基于Reactor的基于事件驱动的IO网络模型吗?

TRANS_BY_GITHUB_AI_ASSISTANT

About ThreadLoadCounter Statistics Issues

ThreadPool(int num = 1,
               Priority priority = PRIORITY_HIGHEST,
               bool autoRun = true) ;

ThreadPool allows the creation of multiple threads. In ThreadPool::run(), calling startSleep() and sleepWakeUp() performs load statistics. When the number of threads is greater than 1, is the load statistics inaccurate?

ThreadPool(int num = 1, Priority priority = PRIORITY_HIGHEST, bool autoRun = true) ;

ThreadPool允许创建多条线程. 在ThreadPool::run()中调用startSleep()与sleepWakeUp()进行load统计,当线程数大于1时,load统计是否不准确?

TRANS_BY_GITHUB_AI_ASSISTANT

Android compilation error

  • ndk is android-ndk-r14b
  • System is macOS Big Sur 11.5.2

Running build_for_android.sh directly under the ZLToolKit directory results in the following error

ZLToolKit/src/Network/Session.cpp: In member function 'virtual std::string toolkit::Session::getIdentifier() const':
ZLToolKit/src/Network/Session.cpp:21:12: error: 'to_string' is not a member of 'std'
     return std::to_string(reinterpret_cast<uint64_t>(this));
            ^
ZLToolKit/src/Network/Session.cpp:21:12: note: suggested alternative:
In file included from ZLToolKit/src/Network/Socket.h:22:0,
                 from ZLToolKit/src/Network/Session.h:16,
                 from ZLToolKit/src/Network/Session.cpp:11:
ZLToolKit/src/Util/util.h:209:13: note:   'toolkit::to_string'
 std::string to_string(T value){
             ^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-predefined-identifier-outside-function"
make[2]: *** [CMakeFiles/ZLToolKit_static.dir/src/Network/Session.cpp.o] Error 1
make[1]: *** [CMakeFiles/ZLToolKit_static.dir/all] Error 2
make: *** [all] Error 2
  • ndk 是 android-ndk-r14b
  • 系统是 macOS Big Sur 11.5.2

在 ZLToolKit 目录下直接运行 build_for_android.sh,报以下错误

ZLToolKit/src/Network/Session.cpp: In member function 'virtual std::string toolkit::Session::getIdentifier() const':
ZLToolKit/src/Network/Session.cpp:21:12: error: 'to_string' is not a member of 'std'
     return std::to_string(reinterpret_cast<uint64_t>(this));
            ^
ZLToolKit/src/Network/Session.cpp:21:12: note: suggested alternative:
In file included from ZLToolKit/src/Network/Socket.h:22:0,
                 from ZLToolKit/src/Network/Session.h:16,
                 from ZLToolKit/src/Network/Session.cpp:11:
ZLToolKit/src/Util/util.h:209:13: note:   'toolkit::to_string'
 std::string to_string(T value){
             ^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-predefined-identifier-outside-function"
make[2]: *** [CMakeFiles/ZLToolKit_static.dir/src/Network/Session.cpp.o] Error 1
make[1]: *** [CMakeFiles/ZLToolKit_static.dir/all] Error 2
make: *** [all] Error 2

TRANS_BY_GITHUB_AI_ASSISTANT

./test_ringBuffer terminate called without an active exception

ubuntu18.04 running test_ringBuffer encountered an error, the debugging log is as follows:

vroot@vroot-ThinkPad-E14:~/604/ZLToolKit/build$ gdb ./bin/test_ringBuffer 



(gdb) r
Starting program: /home/vroot/604/ZLToolKit/build/bin/test_ringBuffer 
warning: File "/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libpthread-2.27.so-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "/home/vroot/".
To enable execution of this file add
        add-auto-load-safe-path /usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libpthread-2.27.so-gdb.py
line to your configuration file "/home/vroot/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/vroot/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "/home/vroot/".
[New Thread 0x7ffff5985700 (LWP 24791)]
[New Thread 0x7ffff5184700 (LWP 24792)]
2021-01-04 10:48:04.463 D test_ringBuffer[24784] util.cpp:324 operator() | Stamp thread started!
[New Thread 0x7ffff4983700 (LWP 24793)]
[New Thread 0x7fffe7fff700 (LWP 24794)]
[New Thread 0x7fffe77fe700 (LWP 24795)]
[New Thread 0x7fffe6ffd700 (LWP 24796)]
[New Thread 0x7fffe67fc700 (LWP 24797)]
[New Thread 0x7fffe5ffb700 (LWP 24798)]
[New Thread 0x7fffe57fa700 (LWP 24799)]
[New Thread 0x7fffe4ff9700 (LWP 24800)]
2021-01-04 10:48:04.465 I test_ringBuffer[24784] EventPoller.cpp:466 EventPollerPool | 创建EventPoller个数:8
[New Thread 0x7fffc7fff700 (LWP 24801)]
2021-01-04 10:48:04.465 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 1
2021-01-04 10:48:04.565 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 2
2021-01-04 10:48:04.666 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 3
2021-01-04 10:48:04.766 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 4
2021-01-04 10:48:04.866 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 5
2021-01-04 10:48:04.966 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 6
2021-01-04 10:48:05.067 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 7
2021-01-04 10:48:05.167 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 8
2021-01-04 10:48:05.267 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 9
2021-01-04 10:48:05.367 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 10
2021-01-04 10:48:05.467 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 11
2021-01-04 10:48:05.568 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 12
2021-01-04 10:48:05.668 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 13
2021-01-04 10:48:05.768 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 14
2021-01-04 10:48:05.868 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 15
2021-01-04 10:48:05.969 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 16
2021-01-04 10:48:06.069 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 17
2021-01-04 10:48:06.169 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 18
2021-01-04 10:48:06.269 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 19
2021-01-04 10:48:06.369 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 20
2021-01-04 10:48:06.470 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 21
2021-01-04 10:48:06.570 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 22
2021-01-04 10:48:06.670 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 23
2021-01-04 10:48:06.770 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 24
2021-01-04 10:48:06.871 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 25
2021-01-04 10:48:06.971 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 26
2021-01-04 10:48:07.071 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 27
2021-01-04 10:48:07.171 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 28
2021-01-04 10:48:07.271 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 29
2021-01-04 10:48:07.372 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 30
[Thread 0x7fffc7fff700 (LWP 24801) exited]
2021-01-04 10:48:07.472 W test_ringBuffer[24784] test_ringBuffer.cpp:36 onDetachEvent | 
terminate called without an active exception
[Thread 0x7fffe7fff700 (LWP 24794) exited]
2021-01-04 10:48:08.473 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e62e0
2021-01-04 10:48:08.473 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e67a0
2021-01-04 10:48:08.474 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e6c60
2021-01-04 10:48:08.474 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e70c0
2021-01-04 10:48:08.475 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e75e0
2021-01-04 10:48:08.475 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e7a70
[Thread 0x7fffe57fa700 (LWP 24799) exited]
[Thread 0x7fffe67fc700 (LWP 24797) exited]
[Thread 0x7fffe5ffb700 (LWP 24798) exited]
[Thread 0x7fffe77fe700 (LWP 24795) exited]
[Thread 0x7fffe6ffd700 (LWP 24796) exited]

Thread 4 "test_ringBuffer" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff4983700 (LWP 24793)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.





(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6e95921 in __GI_abort () at abort.c:79
#2  0x00007ffff74ea957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff74f0ae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff74f0b21 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00005555555a7993 in std::thread::~thread() ()
#6  0x00007ffff7b39341 in toolkit::EventPoller::shutdown() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#7  0x00007ffff7b393d8 in toolkit::EventPoller::~EventPoller() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#8  0x00007ffff7b39552 in toolkit::EventPoller::~EventPoller() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#9  0x00007ffff7b4bdaa in std::_Sp_counted_ptr<toolkit::EventPoller*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#10 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#11 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#12 0x00005555555a879e in std::__shared_ptr<toolkit::EventPoller, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() ()
#13 0x00005555555a87ba in std::shared_ptr<toolkit::EventPoller>::~shared_ptr() ()
#14 0x00005555555aa110 in toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}::~_RingReaderDispatcher() ()
#15 0x00005555555b9652 in std::_Sp_ebo_helper<0, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, false>::~_Sp_ebo_helper() ()
#16 0x00005555555b966e in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Impl::~_Impl() ()
#17 0x00005555555be6c6 in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::~_Sp_counted_deleter() ()
#18 0x00005555555be792 in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_destroy() ()
#19 0x00005555555ad71e in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_weak_release() ()
#20 0x00005555555ab18f in std::__weak_count<(__gnu_cxx::_Lock_policy)2>::~__weak_count() ()
#21 0x00005555555ac478 in std::__weak_ptr<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, (__gnu_cxx::_Lock_policy)2>::~__weak_ptr() ()
#22 0x00005555555ac494 in std::weak_ptr<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~weak_ptr() ()
#23 0x00005555555ac74c in toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}::~_RingReader() ()
#24 0x00005555555b625e in std::_Function_base::_Base_manager<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}>::_M_destroy(std::_Any_data&, std::integral_constant<bool, false>) ()
#25 0x00005555555b250c in std::_Function_base::_Base_manager<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}>::_M_manager(std::_Any_data&, toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1} const&, std::_Manager_operation) ()
#26 0x00005555555a7fc3 in std::_Function_base::~_Function_base() ()
#27 0x00005555555a7ff6 in std::function<void ()>::~function() ()
#28 0x00007ffff7b4c17e in void __gnu_cxx::new_allocator<std::function<void ()> >::destroy<std::function<void ()> >(std::function<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#29 0x00007ffff7b4bfbf in void std::allocator_traits<std::allocator<std::function<void ()> > >::destroy<std::function<void ()> >(std::allocator<std::function<void ()> >&, std::function<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#30 0x00007ffff7b4b83d in std::_Sp_counted_ptr_inplace<std::function<void ()>, std::allocator<std::function<void ()> >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#31 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#32 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#33 0x00007ffff7b3ede8 in std::__shared_ptr<std::function<void ()>, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#34 0x00007ffff7b3ee04 in std::shared_ptr<std::function<void ()> >::~shared_ptr() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#35 0x00007ffff7b4b5dc in toolkit::TaskCancelableImp<void ()>::~TaskCancelableImp() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#36 0x00007ffff7b4c1e7 in void __gnu_cxx::new_allocator<toolkit::TaskCancelableImp<void ()> >::destroy<toolkit::TaskCancelableImp<void ()> >(toolkit::TaskCancelableImp<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#37 0x00007ffff7b4c03f in void std::allocator_traits<std::allocator<toolkit::TaskCancelableImp<void ()> > >::destroy<toolkit::TaskCancelableImp<void ()> >(std::allocator<toolkit::TaskCancelableImp<void ()> >&, toolkit::TaskCancelableImp<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#38 0x00007ffff7b4bb25 in std::_Sp_counted_ptr_inplace<toolkit::TaskCancelableImp<void ()>, std::allocator<toolkit::TaskCancelableImp<void ()> >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#39 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#40 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#41 0x00005555555a809e in std::__shared_ptr<toolkit::TaskCancelableImp<void ()>, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() ()
#42 0x00005555555a80ba in std::shared_ptr<toolkit::TaskCancelableImp<void ()> >::~shared_ptr() ()
#43 0x00007ffff7b42628 in toolkit::ListNode<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::~ListNode() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#44 0x00007ffff7b40950 in toolkit::List<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::clear() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#45 0x00007ffff7b3ec68 in toolkit::List<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::~List() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#46 0x00007ffff7b3e2f7 in toolkit::EventPoller::onPipeEvent() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#47 0x00007ffff7b38d96 in toolkit::EventPoller::EventPoller(toolkit::ThreadPool::Priority)::{lambda(int)#1}::operator()(int) const () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#48 0x00007ffff7b3ba03 in std::_Function_handler<void (int), toolkit::EventPoller::EventPoller(toolkit::ThreadPool::Priority)::{lambda(int)#1}>::_M_invoke(std::_Any_data const&, int&&) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#49 0x00005555555ae4de in std::function<void (int)>::operator()(int) const ()
#50 0x00007ffff7b3a831 in toolkit::EventPoller::runLoop(bool, bool) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#51 0x00007ffff7b41b01 in void std::__invoke_impl<void, void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>(std::__invoke_memfun_deref, void (toolkit::EventPoller::*&&)(bool, bool), toolkit::EventPoller*&&, bool&&, bool&&) ()
   from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#52 0x00007ffff7b3fd1b in std::__invoke_result<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>::type std::__invoke<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>(void (toolkit::EventPoller::*&&)(bool, bool), toolkit::EventPoller*&&, bool&&, bool&&) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#53 0x00007ffff7b4c283 in decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)(), (_S_declval<2ul>)(), (_S_declval<3ul>)())) std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#54 0x00007ffff7b4c0ae in std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> >::operator()() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#55 0x00007ffff7b4be72 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> > >::_M_run() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#56 0x00007ffff751b6df in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#57 0x00007ffff77ee6db in start_thread (arg=0x7ffff4983700) at pthread_create.c:463
#58 0x00007ffff6f7671f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) 

ubuntu18.04 运行test_ringBuffer时候出错,调试log如下:

vroot@vroot-ThinkPad-E14:~/604/ZLToolKit/build$ gdb ./bin/test_ringBuffer 



(gdb) r
Starting program: /home/vroot/604/ZLToolKit/build/bin/test_ringBuffer 
warning: File "/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libpthread-2.27.so-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "/home/vroot/".
To enable execution of this file add
        add-auto-load-safe-path /usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libpthread-2.27.so-gdb.py
line to your configuration file "/home/vroot/.gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/vroot/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "/home/vroot/".
[New Thread 0x7ffff5985700 (LWP 24791)]
[New Thread 0x7ffff5184700 (LWP 24792)]
2021-01-04 10:48:04.463 D test_ringBuffer[24784] util.cpp:324 operator() | Stamp thread started!
[New Thread 0x7ffff4983700 (LWP 24793)]
[New Thread 0x7fffe7fff700 (LWP 24794)]
[New Thread 0x7fffe77fe700 (LWP 24795)]
[New Thread 0x7fffe6ffd700 (LWP 24796)]
[New Thread 0x7fffe67fc700 (LWP 24797)]
[New Thread 0x7fffe5ffb700 (LWP 24798)]
[New Thread 0x7fffe57fa700 (LWP 24799)]
[New Thread 0x7fffe4ff9700 (LWP 24800)]
2021-01-04 10:48:04.465 I test_ringBuffer[24784] EventPoller.cpp:466 EventPollerPool | 创建EventPoller个数:8
[New Thread 0x7fffc7fff700 (LWP 24801)]
2021-01-04 10:48:04.465 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 1
2021-01-04 10:48:04.565 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 2
2021-01-04 10:48:04.666 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 3
2021-01-04 10:48:04.766 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 4
2021-01-04 10:48:04.866 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 5
2021-01-04 10:48:04.966 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 6
2021-01-04 10:48:05.067 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 7
2021-01-04 10:48:05.167 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 8
2021-01-04 10:48:05.267 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 9
2021-01-04 10:48:05.367 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 10
2021-01-04 10:48:05.467 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 11
2021-01-04 10:48:05.568 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 12
2021-01-04 10:48:05.668 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 13
2021-01-04 10:48:05.768 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 14
2021-01-04 10:48:05.868 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 15
2021-01-04 10:48:05.969 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 16
2021-01-04 10:48:06.069 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 17
2021-01-04 10:48:06.169 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 18
2021-01-04 10:48:06.269 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 19
2021-01-04 10:48:06.369 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 20
2021-01-04 10:48:06.470 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 21
2021-01-04 10:48:06.570 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 22
2021-01-04 10:48:06.670 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 23
2021-01-04 10:48:06.770 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 24
2021-01-04 10:48:06.871 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 25
2021-01-04 10:48:06.971 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 26
2021-01-04 10:48:07.071 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 27
2021-01-04 10:48:07.171 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 28
2021-01-04 10:48:07.271 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 29
2021-01-04 10:48:07.372 D test_ringBuffer[24784] test_ringBuffer.cpp:31 onReadEvent | 30
[Thread 0x7fffc7fff700 (LWP 24801) exited]
2021-01-04 10:48:07.472 W test_ringBuffer[24784] test_ringBuffer.cpp:36 onDetachEvent | 
terminate called without an active exception
[Thread 0x7fffe7fff700 (LWP 24794) exited]
2021-01-04 10:48:08.473 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e62e0
2021-01-04 10:48:08.473 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e67a0
2021-01-04 10:48:08.474 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e6c60
2021-01-04 10:48:08.474 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e70c0
2021-01-04 10:48:08.475 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e75e0
2021-01-04 10:48:08.475 I test_ringBuffer[24784] EventPoller.cpp:95 ~EventPoller | 0x5555557e7a70
[Thread 0x7fffe57fa700 (LWP 24799) exited]
[Thread 0x7fffe67fc700 (LWP 24797) exited]
[Thread 0x7fffe5ffb700 (LWP 24798) exited]
[Thread 0x7fffe77fe700 (LWP 24795) exited]
[Thread 0x7fffe6ffd700 (LWP 24796) exited]

Thread 4 "test_ringBuffer" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff4983700 (LWP 24793)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.





(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6e95921 in __GI_abort () at abort.c:79
#2  0x00007ffff74ea957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff74f0ae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff74f0b21 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00005555555a7993 in std::thread::~thread() ()
#6  0x00007ffff7b39341 in toolkit::EventPoller::shutdown() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#7  0x00007ffff7b393d8 in toolkit::EventPoller::~EventPoller() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#8  0x00007ffff7b39552 in toolkit::EventPoller::~EventPoller() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#9  0x00007ffff7b4bdaa in std::_Sp_counted_ptr<toolkit::EventPoller*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#10 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#11 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#12 0x00005555555a879e in std::__shared_ptr<toolkit::EventPoller, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() ()
#13 0x00005555555a87ba in std::shared_ptr<toolkit::EventPoller>::~shared_ptr() ()
#14 0x00005555555aa110 in toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}::~_RingReaderDispatcher() ()
#15 0x00005555555b9652 in std::_Sp_ebo_helper<0, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, false>::~_Sp_ebo_helper() ()
#16 0x00005555555b966e in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Impl::~_Impl() ()
#17 0x00005555555be6c6 in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::~_Sp_counted_deleter() ()
#18 0x00005555555be792 in std::_Sp_counted_deleter<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*, toolkit::RingBuffer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#2}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_destroy() ()
#19 0x00005555555ad71e in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_weak_release() ()
#20 0x00005555555ab18f in std::__weak_count<(__gnu_cxx::_Lock_policy)2>::~__weak_count() ()
#21 0x00005555555ac478 in std::__weak_ptr<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, (__gnu_cxx::_Lock_policy)2>::~__weak_ptr() ()
#22 0x00005555555ac494 in std::weak_ptr<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~weak_ptr() ()
#23 0x00005555555ac74c in toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}::~_RingReader() ()
#24 0x00005555555b625e in std::_Function_base::_Base_manager<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}>::_M_destroy(std::_Any_data&, std::integral_constant<bool, false>) ()
#25 0x00005555555b250c in std::_Function_base::_Base_manager<toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1}>::_M_manager(std::_Any_data&, toolkit::_RingReaderDispatcher<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::attach(std::shared_ptr<toolkit::EventPoller> const&, bool)::{lambda(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)#1}::operator()(toolkit::_RingReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*) const::{lambda()#1} const&, std::_Manager_operation) ()
#26 0x00005555555a7fc3 in std::_Function_base::~_Function_base() ()
#27 0x00005555555a7ff6 in std::function<void ()>::~function() ()
#28 0x00007ffff7b4c17e in void __gnu_cxx::new_allocator<std::function<void ()> >::destroy<std::function<void ()> >(std::function<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#29 0x00007ffff7b4bfbf in void std::allocator_traits<std::allocator<std::function<void ()> > >::destroy<std::function<void ()> >(std::allocator<std::function<void ()> >&, std::function<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#30 0x00007ffff7b4b83d in std::_Sp_counted_ptr_inplace<std::function<void ()>, std::allocator<std::function<void ()> >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#31 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#32 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#33 0x00007ffff7b3ede8 in std::__shared_ptr<std::function<void ()>, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#34 0x00007ffff7b3ee04 in std::shared_ptr<std::function<void ()> >::~shared_ptr() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#35 0x00007ffff7b4b5dc in toolkit::TaskCancelableImp<void ()>::~TaskCancelableImp() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#36 0x00007ffff7b4c1e7 in void __gnu_cxx::new_allocator<toolkit::TaskCancelableImp<void ()> >::destroy<toolkit::TaskCancelableImp<void ()> >(toolkit::TaskCancelableImp<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#37 0x00007ffff7b4c03f in void std::allocator_traits<std::allocator<toolkit::TaskCancelableImp<void ()> > >::destroy<toolkit::TaskCancelableImp<void ()> >(std::allocator<toolkit::TaskCancelableImp<void ()> >&, toolkit::TaskCancelableImp<void ()>*) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#38 0x00007ffff7b4bb25 in std::_Sp_counted_ptr_inplace<toolkit::TaskCancelableImp<void ()>, std::allocator<toolkit::TaskCancelableImp<void ()> >, (__gnu_cxx::_Lock_policy)2>::_M_dispose() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#39 0x00005555555aa92c in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#40 0x00005555555a8af9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() ()
#41 0x00005555555a809e in std::__shared_ptr<toolkit::TaskCancelableImp<void ()>, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() ()
#42 0x00005555555a80ba in std::shared_ptr<toolkit::TaskCancelableImp<void ()> >::~shared_ptr() ()
#43 0x00007ffff7b42628 in toolkit::ListNode<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::~ListNode() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#44 0x00007ffff7b40950 in toolkit::List<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::clear() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#45 0x00007ffff7b3ec68 in toolkit::List<std::shared_ptr<toolkit::TaskCancelableImp<void ()> > >::~List() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#46 0x00007ffff7b3e2f7 in toolkit::EventPoller::onPipeEvent() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#47 0x00007ffff7b38d96 in toolkit::EventPoller::EventPoller(toolkit::ThreadPool::Priority)::{lambda(int)#1}::operator()(int) const () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#48 0x00007ffff7b3ba03 in std::_Function_handler<void (int), toolkit::EventPoller::EventPoller(toolkit::ThreadPool::Priority)::{lambda(int)#1}>::_M_invoke(std::_Any_data const&, int&&) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#49 0x00005555555ae4de in std::function<void (int)>::operator()(int) const ()
#50 0x00007ffff7b3a831 in toolkit::EventPoller::runLoop(bool, bool) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#51 0x00007ffff7b41b01 in void std::__invoke_impl<void, void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>(std::__invoke_memfun_deref, void (toolkit::EventPoller::*&&)(bool, bool), toolkit::EventPoller*&&, bool&&, bool&&) ()
   from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#52 0x00007ffff7b3fd1b in std::__invoke_result<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>::type std::__invoke<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool>(void (toolkit::EventPoller::*&&)(bool, bool), toolkit::EventPoller*&&, bool&&, bool&&) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#53 0x00007ffff7b4c283 in decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)(), (_S_declval<2ul>)(), (_S_declval<3ul>)())) std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#54 0x00007ffff7b4c0ae in std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> >::operator()() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#55 0x00007ffff7b4be72 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (toolkit::EventPoller::*)(bool, bool), toolkit::EventPoller*, bool, bool> > >::_M_run() () from /home/vroot/604/ZLToolKit/build/lib/libZLToolKit.so
#56 0x00007ffff751b6df in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#57 0x00007ffff77ee6db in start_thread (arg=0x7ffff4983700) at pthread_create.c:463
#58 0x00007ffff6f7671f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) 

TRANS_BY_GITHUB_AI_ASSISTANT

Compilation Issues with g_defaultLogger on Windows

VS2017, when compiling ALL_BUILD, the following problem occurs:

test_logger.obj : error LNK2019: 无法解析的外部符号 "class toolkit::Logger * toolkit::g_defaultLogger" (?g_defaultLogger@toolkit@@3PAVLogger@1@A),该符号在函数 _main 中被引用

test_delayTask.obj : error LNK2019: 无法解析的外部符号 "class toolkit::Logger * toolkit::g_defaultLogger" (?g_defaultLogger@toolkit@@3PAVLogger@1@A),该符号在函数 "private: virtual void __thiscall std::_Func_impl_no_alloc<class <lambda_1f860e808c4732d9497d62aaa8d648d8>,void>::_Do_call(void)" (?_Do_call@?$_Func_impl_no_alloc@V<lambda_1f860e808c4732d9497d62aaa8d648d8>@@x$$V@std@@EAEXXZ) 中被引用

...

Is there a problem with the reference to the test project?

VS2017,到编译 ALL_BUILD 时,出现如下问题:
test_logger.obj : error LNK2019: 无法解析的外部符号 "class toolkit::Logger * toolkit::g_defaultLogger" (?g_defaultLogger@toolkit@@3PAVLogger@1@A),该符号在函数 _main 中被引用

test_delayTask.obj : error LNK2019: 无法解析的外部符号 "class toolkit::Logger * toolkit::g_defaultLogger" (?g_defaultLogger@toolkit@@3PAVLogger@1@A),该符号在函数 "private: virtual void __thiscall std::_Func_impl_no_alloc<class <lambda_1f860e808c4732d9497d62aaa8d648d8>,void>::_Do_call(void)" (?_Do_call@?$_Func_impl_no_alloc@V<lambda_1f860e808c4732d9497d62aaa8d648d8>@@x$$V@std@@EAEXXZ) 中被引用

...

请问是test项目的引用有问题吗

TRANS_BY_GITHUB_AI_ASSISTANT

I encountered these printing issues after exiting the process.

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

I don't know what this means.

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

Exception at 0x75264592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\kitlib\poller\eventpoller.cpp:87

目前不知道该原因是什么意思

TRANS_BY_GITHUB_AI_ASSISTANT

How does test_tcpClient reconnect in case of errors?

For example, if the server port is closed or the client is disconnected, how can we implement reconnection in test_tcpClient?

比如服务器端口关闭,或者客户端断网等情况,如何在test_tcpClient中实现断线重连呢

TRANS_BY_GITHUB_AI_ASSISTANT

Cross-compilation compilation error

image
Compiling the example will result in an error. Is it possible to skip compiling the example?
arm architecture

image
编译示例的时候会报错, 可以不编译示例吗?
arm架构

TRANS_BY_GITHUB_AI_ASSISTANT

Historical log file cleanup failed

If the program runs continuously and is set to keep only one day's worth of data, the files generated on the first day will not be deleted on the second day. This is a temporary fix I made to the code.
image

如果程序一直运行,并只设置了一天保留,在第二天时并不会删除第一天产生的文件,这是我临时修改的代码
image

TRANS_BY_GITHUB_AI_ASSISTANT

# Code Help

图片
The function Instance() in the logger is not defined. Why can it be used directly? Can any expert give me some pointers?

图片
logger里的函数Instance()没有定义,为什么可以直接使用呢?有大佬可以提点一二吗。

TRANS_BY_GITHUB_AI_ASSISTANT

First, I'd like to give the OP a thumbs up, it's well written. I found a problem during testing, the timer can't exit.

int i = 0;
toolkit::Ticker ticker;
toolkit::Timer::Ptr timer = make_shared<toolkit::Timer>(
    1, [&]() {
        i++;
        cout << i << endl;
        ticker.resetTime();
        if (i == 6)
            return false; //这里返回false 也不能结束定时器
        
        return true;
    },
    nullptr);

//退出程序事件处理
static toolkit::semaphore sem;
signal(SIGINT, [](int) { sem.post(); });
sem.wait();

int i = 0;
toolkit::Ticker ticker;
toolkit::Timer::Ptr timer = make_sharedtoolkit::Timer(
1, & {
i++;
cout << i << endl;
ticker.resetTime();
if (i == 6)
return false; //这里返回false 也不能结束定时器

    return true;
},
nullptr);

//退出程序事件处理
static toolkit::semaphore sem;
signal(SIGINT, { sem.post(); });
sem.wait();


`TRANS_BY_GITHUB_AI_ASSISTANT`

ini file writing issue

ini configuration file How to update to the file using mINI
I use it like this
mINI::Instance()["rtp_proxy.port"] = 1233; mINI::Instance()[RtpProxy::kPort] = 1234;
The ini file is not saved. How can I update it to the file?

ini配置文件 使用mINI如何更新到文件
我这样使用
mINI::Instance()["rtp_proxy.port"] = 1233; mINI::Instance()[RtpProxy::kPort] = 1234;
ini文件没有保存 怎样做可以更新到文件

TRANS_BY_GITHUB_AI_ASSISTANT

Poller thread issues

For example, I have a 4-core machine now, and I start 4 pollers. But every time I get a poller, it's random. How can I ensure that one piece of data is only executed in one poller? If several pollers execute in a loop, will it cause the execution order to be incorrect and lead to data inconsistency?

比如我现在4核的机器,我启动的4个poller,但是我每次getpoller都是随机的,我如何能保证我一个数据只能在一个poller里面执行,如果是几个poller循环执行,会不会导致执行顺序不对导致数据不对的现象?

TRANS_BY_GITHUB_AI_ASSISTANT

undefined reference to `__atomic_load_8'

If you encounter the above problem, you need to add set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")

遇到上述问题,需要加set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic")

TRANS_BY_GITHUB_AI_ASSISTANT

The _mtx_socket issue in the Socket class

Analyzing the author's network library, I'm confused about the _mtx_socket member of Socket.

In TcpServer.h:

virtual Socket::Ptr onBeforeAcceptConnection(const EventPoller::Ptr &poller){
/**
* 服务器器模型socket是线程安全的,所以为了提高性能,关闭互斥锁
*/
return std::make_shared(poller,false);
}

The server model is thread-safe because socket read/write/timeout/close operations are executed sequentially in one thread. There is no need for mutexes. Therefore, to improve performance, the mutex is closed.

Then why is the non-server model not thread-safe? Specifically,

commit a549490 Jzan [email protected] on 3/5/17 at 6:20 PM

What is the scenario based on?

正在分析作者的网络库 对Socket的成员_mtx_socket很疑惑
TcpServer.h中

virtual Socket::Ptr onBeforeAcceptConnection(const EventPoller::Ptr &poller){
        /**
         * 服务器器模型socket是线程安全的,所以为了提高性能,关闭互斥锁
         */
        return std::make_shared<Socket>(poller,false);
    }

服务器模型是线程安全的 因为socket的读/写/超时/关闭 都是在一个线程中顺序执行的 不需要互斥量 所以为了提高性能 关闭互斥锁
那么非服务器模型 为什么线程不安全的呢? 具体而言就是

commit a549490e Jzan <[email protected]> on 3/5/17 at 6:20 PM

是基于什么场景呢?

TRANS_BY_GITHUB_AI_ASSISTANT

Is the `send` method thread-safe?

Multiple threads call the send method simultaneously, for example:
Thread A: send("hello");
Thread B: send("world");
Thread C: send("china");
It is impossible for the sent order or the received order to be like this: "hechillonaworld".
The send buffer is atomic and indivisible.

多个线程都同时调用了send方法,比如:
Thread A: send("hello");
Thread B: send("world");
Thread C: send("china");
发出去的顺序或者接收到的,不可能存在这种情况吧:"hechillonaworld"。
send的buffer是原子性不可分割的。

TRANS_BY_GITHUB_AI_ASSISTANT

Compilation failed

Environment is ubuntu 17.10 64bit
gcc version gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)

Error log is as follows:

./build_for_linux.sh
-- 找到openssl库:"/usr/include",ENABLE_OPENSSL宏已打开
-- Found MySQL: /usr/include, /usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- MySQL Embedded not found.
-- 找到mysqlclient库:"/usr/include",ENABLE_MYSQL宏已打开
-- 将链接依赖库:/usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- 添加测试程序:test_asyncTaskThrad
-- 添加测试程序:test_eventPoller
-- 添加测试程序:test_logger
-- 添加测试程序:test_noticeCenter
-- 添加测试程序:test_pipe
-- 添加测试程序:test_resourcePool
-- 添加测试程序:test_ringBuffer
-- 添加测试程序:test_rwmutex
-- 添加测试程序:test_semaphore
-- 添加测试程序:test_shell
-- 添加测试程序:test_spin_mutex
-- 添加测试程序:test_sql
-- 添加测试程序:test_ssl
-- 添加测试程序:test_tcpClient
-- 添加测试程序:test_tcpEchoServer
-- 添加测试程序:test_threadPool
-- 添加测试程序:test_threadPoolBenchmark
-- 添加测试程序:test_udpSock
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhang/src/cpp/ZLToolKit/linux_build
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/SqlConnection.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/File.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/util.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/MD5.cpp.o
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/ZLToolKit_static.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/SSLBox.cpp.o
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/ZLToolKit_static.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_static.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

It looks like function templates are not supported. What should I do?

环境是 ubuntu 17.10 64bit
gcc 版本 gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)

错误记录如下:

./build_for_linux.sh
-- 找到openssl库:"/usr/include",ENABLE_OPENSSL宏已打开
-- Found MySQL: /usr/include, /usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- MySQL Embedded not found.
-- 找到mysqlclient库:"/usr/include",ENABLE_MYSQL宏已打开
-- 将链接依赖库:/usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libmysqlclient.so
-- 添加测试程序:test_asyncTaskThrad
-- 添加测试程序:test_eventPoller
-- 添加测试程序:test_logger
-- 添加测试程序:test_noticeCenter
-- 添加测试程序:test_pipe
-- 添加测试程序:test_resourcePool
-- 添加测试程序:test_ringBuffer
-- 添加测试程序:test_rwmutex
-- 添加测试程序:test_semaphore
-- 添加测试程序:test_shell
-- 添加测试程序:test_spin_mutex
-- 添加测试程序:test_sql
-- 添加测试程序:test_ssl
-- 添加测试程序:test_tcpClient
-- 添加测试程序:test_tcpEchoServer
-- 添加测试程序:test_threadPool
-- 添加测试程序:test_threadPoolBenchmark
-- 添加测试程序:test_udpSock
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhang/src/cpp/ZLToolKit/linux_build
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/SqlConnection.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/File.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Util/util.cpp.o
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/MD5.cpp.o
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/ZLToolKit_static.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_static.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[  1%] Building CXX object CMakeFiles/ZLToolKit_static.dir/src/Util/SSLBox.cpp.o
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/ZLToolKit_static.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_static.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
[  1%] Building CXX object CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o
In file included from /home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:27:0:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:50:2: error: ‘function’ does not name a type; did you mean ‘union’?
  function<bool()> task;
  ^~~~~~~~
  union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:62: error: ‘function’ does not name a type; did you mean ‘union’?
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                              ^~~~~~~~
                                                              union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:59:70: error: expected ‘,’ or ‘...’ before ‘<’ token
  void DoTaskDelay(uint64_t type, uint64_t millisecond, const function<bool()> &func);
                                                                      ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:45: error: ‘function’ does not name a type; did you mean ‘union’?
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                             ^~~~~~~~
                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:83:53: error: expected ‘,’ or ‘...’ before ‘<’ token
  AsyncTaskHelper(uint64_t millisecond,const function<bool()> &task){
                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h: In constructor ‘ZL::Thread::AsyncTaskHelper::AsyncTaskHelper(uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.h:84:88: error: ‘task’ was not declared in this scope
   AsyncTaskThread::Instance().DoTaskDelay(reinterpret_cast<uint64_t>(this),millisecond,task);
                                                                                        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: At global scope:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:77: error: ‘function’ does not name a type; did you mean ‘union’?
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                             ^~~~~~~~
                                                                             union
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:50:85: error: expected ‘,’ or ‘...’ before ‘<’ token
 void AsyncTaskThread::DoTaskDelay(uint64_t type, uint64_t millisecond,const function<bool()> &func) {
                                                                                     ^
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTaskDelay(uint64_t, uint64_t, int)’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:8: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
  info->task = func;
        ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: error: ‘func’ was not declared in this scope
  info->task = func;
               ^~~~
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:55:15: note: suggested alternative: ‘sync’
  info->task = func;
               ^~~~
               sync
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp: In member function ‘void ZL::Thread::AsyncTaskThread::DoTask()’:
/home/zhang/src/cpp/ZLToolKit/src/Thread/AsyncTaskThread.cpp:100:18: error: ‘using element_type = struct ZL::Thread::TaskInfo {aka struct ZL::Thread::TaskInfo}’ has no member named ‘task’
     flag = info->task();
                  ^~~~
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-predefined-identifier-outside-function’
CMakeFiles/ZLToolKit_shared.dir/build.make:254: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o' failed
make[2]: *** [CMakeFiles/ZLToolKit_shared.dir/src/Thread/AsyncTaskThread.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ZLToolKit_shared.dir/all' failed
make[1]: *** [CMakeFiles/ZLToolKit_shared.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

看上去像是function模板不支持,应该怎么办?

TRANS_BY_GITHUB_AI_ASSISTANT

Does UDP have performance optimizations similar to TcpServer?

It seems that the UDP server is mainly used in RTSP and RTProxy, where performance requirements may not be high.

My situation is that I need a server that mainly accesses through UDP. Is there an optimized solution similar to TcpServer?

There is only one TCP connect interface here:
https://github.com/xiongziliang/ZLToolKit/blob/ed47015f92cc79dfe3344b3666aafb54f1bbc2f4/src/Network/sockutil.h#L62

UDP can also connect:

   If the socket sockfd is of type SOCK_DGRAM, then addr is the address to
   which datagrams are sent by default, and the only  address  from  which
   datagrams  are  received.   If  the  socket  is  of type SOCK_STREAM or
   SOCK_SEQPACKET, this call attempts to make a connection to  the  socket
   that is bound to the address specified by addr.

If we connect both ways, can we achieve a similar effect to TcpServer? If there are any related changes, will you consider merging them into the project?

目前看 udp server 主要看主要是在 rtsp 及 rtpproxy 部分用到, 对性能要求可能不高.

我这边的情况是需要一个及主要通过 udp 接入的服务器, 这边是否有类似 TcpServer 这样的优化方案呢?

这里只有一个 tcp 的 connect 接口
https://github.com/xiongziliang/ZLToolKit/blob/ed47015f92cc79dfe3344b3666aafb54f1bbc2f4/src/Network/sockutil.h#L62

udp 也可以 connect

   If the socket sockfd is of type SOCK_DGRAM, then addr is the address to
   which datagrams are sent by default, and the only  address  from  which
   datagrams  are  received.   If  the  socket  is  of type SOCK_STREAM or
   SOCK_SEQPACKET, this call attempts to make a connection to  the  socket
   that is bound to the address specified by addr.

这样如果双向 connect 一下, 是否可以实现类似 TcpServer 中的效果? 这部分相关的改动如果有的话, 是否会考虑合到项目中?

TRANS_BY_GITHUB_AI_ASSISTANT

QML C++ Exception Error

In qml, if you create a UDP port with Socket::Ptr sockRecv(new Socket());, then close the program, you will get the following error:

Exception at 0x743e4592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\poller\eventpoller.cpp:87

qml 里面只要 Socket::Ptr sockRecv(new Socket());//创建一个UDP端口,然后关闭程序会报这样的错误
Exception at 0x743e4592, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) at e:\xxxx\poller\eventpoller.cpp:87

TRANS_BY_GITHUB_AI_ASSISTANT

In the logger, due to time zone issues, today's logs may be written to yesterday's file.

Issue:

The logger, due to time zone issues, may write today's logs to yesterday's file.

Branch

master

Platform

windows

Reason:

https://github.com/xia-chu/ZLToolKit/blob/master/src/Util/logger.cpp#L406
auto day = getDay(ctx->_tv.tv_sec); uses UTC time here.

This leads to the subsequent judgment of if (day != _last_day) in the +8 time zone, writing the log file to the previous day's time.

For example, today is 20200804, in Beijing time 20200804, 00-08h time, all belong to 20200803 UTC time.

This leads to logs from 00-08h Beijing time being written to the 2020-08-03.log file.

问题:

logger中,因为时区问题,会导致今天的日志,写在昨天的文件中。

分支

master

平台

windows

原因:

https://github.com/xia-chu/ZLToolKit/blob/master/src/Util/logger.cpp#L406
auto day = getDay(ctx->_tv.tv_sec); 这里使用的是UTC时间。

导致后续的判断if (day != _last_day) 在 +8时区的时间内,将日志文件写入前一天时间 。

比如今天20200804,在北京时间 20200804,00-08h时间内,都属于20200803的UTC时间。

导致北京时间00-08h的日志,写入了2020-08-03.log 文件中。

TRANS_BY_GITHUB_AI_ASSISTANT

How to build a high-performance media forwarding server using ZLToolKit

Background Requirements:

The application scenario is similar to an interactive chat live room, where there may be 1-8 guests speaking (video) simultaneously, and n viewers. The server forwards the UDP media data packets uploaded by the guests to the rest of the people in the room.

There is also some simple signaling, such as entering the room, leaving the room, taking the guest seat, leaving the guest seat (becoming a viewer), etc., which we plan to use TCP for.

Rooms are independent of each other, and one server needs to support many rooms at the same time, so the performance requirements for UDP will be high, while TCP is only for signaling and long connection maintenance. The UDP media data packet header will contain the room number and user uid.

The following are the questions:

  1. Can we refer to test_udpSock.cpp for UDP usage? Are there any other things to note about the use of zltoolkit for our scenario, such as avoiding memory copying?
  2. To forward a packet to other people in the room, do we need to maintain a UDP address list of all people in the room and then send it by iterating through it? Does zltoolkit have any other more advanced and efficient methods?
  3. Regarding the room data structure lookup problem, we currently plan to use a UDP port for listening, and the UDP data packet header will carry the room number. We will parse the header to get the room number and then use a map to find the data structure of this room. Another way is to use a UDP port for listening for each room, so that the data received by this UDP port is naturally for this room, avoiding the need for us to use a map to find the room. Which of these two methods will perform better when the number of rooms is large?

背景需求:
应用场景类似互动聊天直播室,可能有1-8个同时说话(视频)的嘉宾,还有n个观众。服务器将嘉宾上传的udp媒体数据包转发给房间其余人。
还有一点简单信令,比如进房间,离开房间,上嘉宾位,离开嘉宾位(变成观众)等,这部分打算用TCP做。
房间之间是相互独立的,一个服务器需要同时支持很多个房间,所以对UDP的性能要求会高,tcp只是信令以及长连接维持。UDP媒体数据包头会包含房间号和用户uid。
问题如下:
1、UDP的使用参考test_udpSock.cpp即可吗,对于我们这种场景需求,zltoolkit的使用上有没什么其他的注意,比如避免内存拷贝等事项?
2、将一个包转发给房间其他人,是自己维护一个房间所有人的udp地址列表,然后遍历发送吗,zltoolkit有没什么其他更高端高效率的办法?
3、关于房间数据结构的查找问题,目前是打算用一个udp端口进行监听,udp数据包头带上房间号,解析包头得到房间号,然后通过map查找到这个房间的数据结构;另外一种方式是,一个房间使用一个udp端口进行监听,这样这个udp端口收到的数据天然就是这个房间的,避免了我们使用map查找房间。请问这两种方式,哪种房间数量多了性能会好些呢?

TRANS_BY_GITHUB_AI_ASSISTANT

Regarding the issue of using EventPollerPool::Instance().getPoller()->doDelayTask() and EventPollerPool::Instance().getPoller()->async() for the heartbeat thread

Now we need to implement an http short link heartbeat interface,

Method 1: Failed

url.append("/acd/api/v1/0/agent/heartbeat");
weak_ptr<WebClient> weakSelf = dynamic_pointer_cast<WebClient>(_client);
EventPollerPool::Instance().getPoller()->async([weakSelf, url]() {
    while (true) {
        sleep(10);
        auto strongSelf=weakSelf.lock();
        if(strongSelf){
            strongSelf->heartbeat(str);
        }
    }
}, true);

Method 2: Failed

EventPollerPool::Instance().getPoller()->doDelayTask(10 * 1000, [weakSelf, url]() {
                auto strongSelf=weakSelf.lock();
                if(strongSelf){
                    strongSelf->heartbeat(str);
                }
                sleep(10);
                return true;
            });

This is the implementation of heartbeat()

void WebClient::heartbeat(const string &url){
    //TraceL << url;
    _heartbeatPost.reset(new HttpRequester);
    _heartbeatPost->setMethod("POST");
    //设置http请求头
    _heartbeatPost->addHeader("Content-Type", "application/json");
    //设置POST参数列表
    Value val;
    val["groupId"] = _groupId;
    val["agentId"] = _agentId;
    _heartbeatPost->setBody(val.toStyledString());
    //InfoL << val.toStyledString();
    //开启请求
    _heartbeatPost->startRequester(url,//url地址
                                   [](const SockException &ex,                          //网络相关的失败信息,如果为空就代表成功
                                      const string &status,                             //http回复的状态码,比如说200/404
                                      const HttpClient::HttpHeader &header,             //http回复头
                                      const string &strRecvBody) {                       //http回复body
                                       //DebugL << "=====================HttpRequester POST==========================";
                                       if (ex) {
                                           //网络相关的错误
                                           WarnL << "heartbeat network err:" << ex.getErrCode() << " " << ex.what();
                                       } else {
                                           TraceL << "heartbeat body:" << strRecvBody;
                                       }
                                   });
}

_heartbeatPost applies for a global variable, but the http package cannot be sent out.
The current method is to apply for a thread and put it in to implement it, but this way of writing is too ugly. Is there any good way to use EventPollerPool::Instance().getPoller() to send the heartbeat request of http?

现在要实现一个http短链接心跳接口,

方法1:失败

url.append("/acd/api/v1/0/agent/heartbeat");
weak_ptr<WebClient> weakSelf = dynamic_pointer_cast<WebClient>(_client);
EventPollerPool::Instance().getPoller()->async([weakSelf, url]() {
    while (true) {
        sleep(10);
        auto strongSelf=weakSelf.lock();
        if(strongSelf){
            strongSelf->heartbeat(str);
        }
    }
}, true);

方法2:失败

EventPollerPool::Instance().getPoller()->doDelayTask(10 * 1000, [weakSelf, url]() {
                auto strongSelf=weakSelf.lock();
                if(strongSelf){
                    strongSelf->heartbeat(str);
                }
                sleep(10);
                return true;
            });

这是heartbeat()的实现方法

void WebClient::heartbeat(const string &url){
    //TraceL << url;
    _heartbeatPost.reset(new HttpRequester);
    _heartbeatPost->setMethod("POST");
    //设置http请求头
    _heartbeatPost->addHeader("Content-Type", "application/json");
    //设置POST参数列表
    Value val;
    val["groupId"] = _groupId;
    val["agentId"] = _agentId;
    _heartbeatPost->setBody(val.toStyledString());
    //InfoL << val.toStyledString();
    //开启请求
    _heartbeatPost->startRequester(url,//url地址
                                   [](const SockException &ex,                          //网络相关的失败信息,如果为空就代表成功
                                      const string &status,                             //http回复的状态码,比如说200/404
                                      const HttpClient::HttpHeader &header,             //http回复头
                                      const string &strRecvBody) {                       //http回复body
                                       //DebugL << "=====================HttpRequester POST==========================";
                                       if (ex) {
                                           //网络相关的错误
                                           WarnL << "heartbeat network err:" << ex.getErrCode() << " " << ex.what();
                                       } else {
                                           TraceL << "heartbeat body:" << strRecvBody;
                                       }
                                   });
}

_heartbeatPost申请的是全局变量,但是http包都发不出去.
现在用的方法是申请一个thread,放进去实现,但是这样写太难看了,请问有什么好方法用EventPollerPool::Instance().getPoller()发http的心跳请求,

TRANS_BY_GITHUB_AI_ASSISTANT

MSVC-CI Build Failure

From the compilation log, it seems that the compiler used is not MSVC:

https://github.com/ZLMediaKit/ZLToolKit/runs/3926875128#step:3:87

https://github.com/ZLMediaKit/ZLToolKit/runs/3926875128#step:3:138

The error message is also inconsistent when compiling locally using MSVC (only a warning about duplicate zltoolkit.lib for dynamic and static libraries is shown). After modification, there are warnings, but it can be compiled normally.

从编译日志看,使用的不是 MSVC 编译器:

https://github.com/ZLMediaKit/ZLToolKit/runs/3926875128#step:3:87

https://github.com/ZLMediaKit/ZLToolKit/runs/3926875128#step:3:138

本地使用 MSVC 编译时错误信息也不一致(只提示了个动静态库的目标有重复 zltoolkit.lib),修改后虽有警告,但可以正常编译。

TRANS_BY_GITHUB_AI_ASSISTANT

Continuous reading will blow up the memory.

When a connection comes in at a very high speed, exceeding the actual processing speed. For example, a server receives an uploaded file. The client uploads the file at a speed of 1G, but the server can only write the file at a speed of 100M per second. In this case, the server will continuously read through epoll, eventually overwhelming the memory.

When the server finds that its cached memory has exceeded a certain threshold, it cannot continue to read until EAGAIN. If it is EDGE-triggered, it has to read again after consuming the cached memory. If it is LEVEL-triggered, it has to call epoll_ctl to delete this fd and then add this fd again after consuming the cached memory.

When the server stops reading, the TCP protocol stack will reduce the TCP wnd, thereby suppressing the sending speed of the sender.

It seems that your library does not have this logic.

当一个连接来的速度很快,多到超过实际处理速度。比如一个server接受上传文件。客户端以1G的速度上传文件,但是该server只能以每秒100M的速度写文件。这种情况下,server会持续的通过epoll读,最终撑爆内存。
当server发现自己缓存的内存已经超过一定阈值,它不能持续read直到EAGAIN。如果是EDGE触发,它得在自己消费完了缓存的内存之后再read,如果是LEVEL触发,它得调用epoll_ctl删除这个fd,并且在自己消费完了缓存的内存之后再加入这个fd。
当server不再read时,tcp协议栈会降低tcp wnd,从而抑制发送方的发送速度。

你这个库里似乎并没有这个逻辑。

TRANS_BY_GITHUB_AI_ASSISTANT

These days, anyone thinks they can write a spinlock?

Not to mention that user space can't block context switch at all, have you even compared your crappy implementation with other implementations? Have you done any performance testing?

https://github.com/xiongziliang/ZLToolKit/blob/7353a131b46ab6af46d9de23078076d1932f33fb/src/Thread/spin_mutex.h#L44

且不说用户态根本无法屏蔽 context switch, 就你这渣渣实现,和 其它实现 比较过吗? 有做过 性能测试 吗?

TRANS_BY_GITHUB_AI_ASSISTANT

About sqlpool

Could you tell me if this database can be made into a multi-instance setup? I mean, can it connect to multiple IPs and multiple databases?

请问下 这个数据库的轮子可以弄成多实例的么 就可以连接几个IP 几个Database的那种

TRANS_BY_GITHUB_AI_ASSISTANT

Can you add a timer?

Can you encapsulate the time wheel using c++11?

能用c++11 封装下timewheel 吗?

TRANS_BY_GITHUB_AI_ASSISTANT

File::loadFile File Reading Issue

大佬, I'm using the code above to read the file, but it's reporting that the corresponding file or directory cannot be found. Using the commented code below works fine, though. The commented code is copied from your source code.
image

string File::loadFile(const char *path) {

大佬, 我用上面这段读取文件会报找不到对应的文件或目录, 用下面注释的运行却正常, 注释的这里是从你源码拷出来的
image

TRANS_BY_GITHUB_AI_ASSISTANT

New multiple tcpclient send message packet loss problem

I created some tcp clients to send messages to the tcpehcosession of this demo, and then the server returns the messages, but I found that the messages received each time are missing. Through network card packet capture, the messages are returned to the client, but I don't know why they didn't come up. In addition, when I control+c tcpehcosession, the client feels that the lost messages are all coming up at this time. Please help me take a look.

Attached is the client code, tcpechosession is only responsible for returning messages, doing nothing

int main() {
    // Set up the logging system
    Logger::Instance().add(std::make_shared<ConsoleChannel>());
	Logger::Instance().add(std::make_shared<FileChannel>());
    Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
	for (int i = 0; i < 200; i++)
	{
		TestClient::Ptr client(new TestClient());//Must use smart pointers
		client->startConnect("192.168.1.189", 40996);//Connect to the server
		testmap.emplace(i, client);
	}
	sleep(30);
	for (auto it = testmap.begin(); it != testmap.end(); it++)
	{
		it->second->send("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
	}

我新建了个一些tcpclient 向这个demo的tcpehcosession 发送消息,然后服务器在将消息返回,但是我发现每次收到的消息都少,通过网卡抓包 消息是回到了client的 不知道什么原因没上来,另外 这个时候我control+c tcpehcosession,这面客户端收感觉丢的消息这个时候就都上来了,请帮我看看

附上client的代码 tcpechosession 就负责回消息,啥都不干

int main() {
// 设置日志系统
Logger::Instance().add(std::make_shared());
Logger::Instance().add(std::make_shared());
Logger::Instance().setWriter(std::make_shared());
for (int i = 0; i < 200; i++)
{
TestClient::Ptr client(new TestClient());//必须使用智能指针
client->startConnect("192.168.1.189", 40996);//连接服务器
testmap.emplace(i, client);
}
sleep(30);
for (auto it = testmap.begin(); it != testmap.end(); it++)
{
it->second->send("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
}

TRANS_BY_GITHUB_AI_ASSISTANT

Discovering significant network congestion using TcpClient and TcpServer

When using TcpClient and TcpServer, I found a lot of TCP Out-of-Order, TCP ACKed unseen segment, Tcp dup ack packets, even when testing on a local area network.
Is this normal? Do you have any good methods for handling TCP network congestion and out-of-order issues?

在用tcpclient和TcpServer的时候发现用大量TCP Out-of-Order,TCP ACKed unseen segment,Tcp dup ack包,还是在局域网情况下测试
请问这正常吗?您对TCP的网络拥塞,乱序问题处理有什么好方法?

TRANS_BY_GITHUB_AI_ASSISTANT

error C2872: “byte”: ambiguous symbol

1>util.cpp
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(192,14): error C2872: “byte”: ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(191,23): message : could be “unsigned char byte”
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\cstddef(29,12): message : or “std::byte”
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(962,25): error C2872: “byte”: ambiguous symbol
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(191,23): message : could be “unsigned char byte”

1>util.cpp
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(192,14): error C2872: “byte”: 不明确的符号
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(191,23): message : 可能是“unsigned char byte”
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\cstddef(29,12): message : 或 “std::byte”
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(962,25): error C2872: “byte”: 不明确的符号
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared\rpcndr.h(191,23): message : 可能是“unsigned char byte”

TRANS_BY_GITHUB_AI_ASSISTANT

Hello, can the socket add support for the reconnect mechanism?

Blogger, the TCP socket used in the project often needs a reconnect mechanism. Can you add a configurable reconnect mechanism to the socket?

博主,项目中用到的tcp socket经常需要用到重连机制,能否在socket中添加个可配置的重连机制

TRANS_BY_GITHUB_AI_ASSISTANT

Please advise on solutions for handling TCP packet fragmentation and packet sticking.

I carefully reviewed the code in your streaming server's HTTP regarding TCP packet merging, but despite my limited knowledge, I still don't understand it very well. I hope the author can explain the general idea of TCP handling packet splitting and merging. I am currently implementing a large file transmission based on ZLToolKit, and I am encountering packet splitting and merging issues.

In addition, I need to implement HTTP file upload now. Do you have a ready-made implementation in your HTTP? Or could you tell me a solution? Thank you very much.

我仔细看了您流媒体服务器中HTTP中关于TCP合包的代码,但是无论才疏学浅,没有很明白,希望作者可以大概讲解下TCP处理拆包粘包的思路,现在基于ZLToolKit要实现一个大文件收发,出现拆包粘包问题.
另外我现在需要实现http上传文件,您的http里面有实现好的吗?或者告诉我一个解决思路,非常感谢

TRANS_BY_GITHUB_AI_ASSISTANT

Receiving Long String Issue

When transferring the base64 string converted from the image using the test example tcp client and echo server, the string received by the server always loses a large part of the string.
image
When printing the length of buf->data() in the above, it is found that it is inconsistent with the client's sending, and it is much smaller.

Thank you very much for your work,

在用测试例子tcp client和echo server传输由图片转成的base64字符串时,服务器端接收的字符串总是丢失一大段字符串
image
在上面的里打印buf->data()的长度发现与client发送的不一致,小了很多

非常感谢大佬的作品,

TRANS_BY_GITHUB_AI_ASSISTANT

_sessionMap consistency issues?

void onManagerSession() {
for (auto &pr : _sessionMap) {
weak_ptr weakSession = pr.second->session();
pr.second->session()->async(weakSession {
auto strongSession=weakSession.lock();
if(!strongSession) {
return;
}
strongSession->onManager();
}, false);
}
}

I'm wondering, when processing this session map, you're iterating through it without any locks. What happens if the map is added to or deleted from while the session is being iterated through? How is consistency maintained? I'm not quite sure.

void onManagerSession() {
for (auto &pr : _sessionMap) {
weak_ptr weakSession = pr.second->session();
pr.second->session()->async(weakSession {
auto strongSession=weakSession.lock();
if(!strongSession) {
return;
}
strongSession->onManager();
}, false);
}
}

请问 在处理这个sessionmap的时候 我卡你这个时候遍历 还是这个seessionmap的添加删除 都没用锁,如果这个seesion遍历的过程中,map被添加或者删除了怎么办,这个是怎么保持一致性的?每太搞明白

TRANS_BY_GITHUB_AI_ASSISTANT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.