Thread Pool API

Thread Pool API

In computer programming, the thread pool pattern (also replicated workers or worker-crew model) is where a number of threads are created to perform a number of tasks, which are usually organized in a queue. The results from the tasks being executed might also be placed in a queue, or the tasks might return no result (for example, if the task is for animation). Typically, there are many more tasks than threads. As soon as a thread completes its task, it will request the next task from the queue until all tasks have been completed. The thread can then terminate, or sleep until there are new tasks available.

A thread pool is a collection of worker threads that efficiently execute asynchronous callbacks on behalf of the application. The thread pool is primarily used to reduce the number of application threads and provide management of the worker threads. Applications can queue work items, associate work with waitable handles, automatically queue based on a timer, and bind with I/O.

The thread pool application programming interface (API) uses an object-based design. Each of the following objects is represented by a user-mode data structure:

• A pool object is a set of worker threads that can be used to perform work. Each process can create multiple isolated pools with different characteristics as necessary. There is also a default pool for each process.

• A clean-up group is associated with a set of callback-generating objects. Functions exists to wait on and release all objects that are members of each clean-up group. This frees the application from keeping track of all the objects it has created.

• A work object is assigned to a pool and optionally to a clean-up group. It can be posted, causing a worker thread from the pool to execute its callback. A work object can have multiple posts outstanding; each generates a callback. The post operation cannot fail due to lack of resources.

• A timer object controls the scheduling of callbacks. Each time a timer expires, its callback is posted to its worker pool. Setting a timer cannot fail due to lack of resources.

• A wait object causes a waiter thread to wait on a waitable handle. After the wait is satisfied or the time-out period expires, the waiter thread posts the wait objects' callback to the wait's worker pool. Setting a wait cannot fail due to lack of resources.

• An I/O object associates a file handle with the I/O completion port for the thread pool. When an asynchronous I/O operation completes, a worker thread picks up the status of the operation and calls the I/O object's callback.


Thread Pool API
added 5 years 3 months ago

Contents related to 'Thread Pool API'

Threading Building Blocks (TBB): Threading Building Blocks (TBB) is a C++ template library developed by Intel for writing software programs that take advantage of multi-core processors.

- Pandas
- Angular JS
- Apache Mahout
- Apache Avro
- EHCache
- Apache Server
- Thread Pool API
- Parallel Patterns Library (PPL)
- Open Multi-Processing (OpenMP, OMP)
- Hibernate ORM
- Integrated Development Environment (IDE)
- Microsoft Message Queuing (MSMQ)
- Representational state transfer (REST) API
- User Datagram Protocol (UDP)
- WildFly (JBoss)
- Message Groups
- OpenWire
- Log4net
- ZeroMq (ØMQ)
- Apache NMS
5
4
3
2
1