chengxumiaodaren / wzq_utils Goto Github PK
View Code? Open in Web Editor NEWc++工具库
c++工具库
环境:wsl2 linux ubuntu20.4 on windows;
触发条件:在执行 test_thread过程中,随机输入回车键,提前销毁线程池对象;
猜测:
1、线程分离,通过回车,线程池管理对象结束了,其他线程依旧在运行中,在运行过程中依旧访问线程池对象的变量,而此时对象中的变量已经销毁,此时再访问可能出现未定义行为,严重可能引发崩溃。
目前只是猜测,未进行深入挖掘分析。
因为非核心线程结束后,worker_threads_并没有减小
建议添加构建命令
cmake .
make
我使用 single.h 中提供的模板类,但在编译的时候,提醒我还要实现undefined reference to `Singleton<Foo>::once_'
和 undefined reference to `Singleton<Foo>::value_'
,我知道这是是要做定义,但不知道该如何使用,对应的test.cc 中也没有使用。
请给一个合理的例子。
~/thread/include/thread/thread_pool.h
129行
// 获取线程池中当前线程的总个数
int GetTotalThreadSize() { return this->worker_threads_.size(); }
按照worker_threads_的容器大小判断线程池数量是不对的,因为非核心线程结束后,不能够自动删除容器中的指针,如果长时间的使用,会浪费很多的内存。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.