Comments (2)
It wouldn't be a very useful thread pool if it wasn't safe to interact with from multiple threads ;)
I'm not sure if I understand your proposed use, though. You don't need a thread to "consume the pool"; the pool itself is composed of worker threads that consume the tasks that you add via the execute
or schedule
interfaces. If you instantiate a threadpool with a maximum worker count of one then it implements the scenario you've described: one worker thread will execute all tasks enqueued via execute
in sequential order.
The workers listen for tasks until the pool is destroyed; the drain
method merely waits until all tasks added prior to its invocation have completed.
from threadpool.
Oh, make sense now. Sorry if my questions was not clear, I'm new to C++ so maybe I didn't asked the right things the right way.
Basically I'm looking to use this in combination with a filesystem watch library that will trigger an event each time a file has changed on disk in some folders. When that happens I just need to execute/queue a task with one param being the file path that was changed. For some reason I was under the impression that only when calling drain the execution of the tasks starts. Makes more sense that drain
just waits.
I think it's clear now. Thank you.
from threadpool.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from threadpool.