xhjcehust / lftpool Goto Github PK
View Code? Open in Web Editor NEWLock-Free Thread Pool
Lock-Free Thread Pool
大佬,想问下这句话如何理解额 对于主线程放入工作和工作线程取出任务的竞争问题,可以采取环形队列的方式避免。 这里主线程插入任务的时候不是向指定pid线程发送信号,然后对应工作线程执行对应任务码,存在什么竞争额不太理解额。
还有是否如果没有任务迁移是否就可以不用在迁出工作使用原子操作比较了
还有这里负载均衡算法是要自己设计吗,然后在合适的时候选择是否增加或者减少线程
还有这个线程池和普通的用互斥量和条件变量的线程池是在什么样的场景下有性能提升额 .....抱歉一下子问了这么多问题....
这个代码有问题,在处理完任务队列内的任务后下一轮循环调用sigwait前,这中间如果主线程往任务线程发送了SIGUSR1信号,那么任务线程就会调用信号处理函数,而这时任务队列非空,下一轮循环的sigwait调用将会一直阻塞等待主线程的通知。
个人认为,线程在处理任务时不应该恢复SIGUSR1信号为异步方式,如果在任务处理周期内收到了一个或多个SIGUSR1信号,未决信号队列只会保留一个SIGUSR1信号,则最多只会导致"while (thread_queue_empty(thread) && !thread->shutdown)"循环空转一轮,但是能使每一个任务都及时的处理。
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.