- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Static Public Member Functions

# MThreadPool Class Reference
OpenMaya - API module for common classes

This reference page is linked to from the following overview topics: API クラスとプラグイン, サンプル C++ プラグインの説明.

Search for all occurrences

## Detailed Description

Methods for creating and managing a thread pool.

MThreadPool class. The thread pool is created with a number of threads equal to one less than the number of logical processors.

`#include <MThreadPool.h>`

List of all members.

## Static Public Member Functions
static MStatus | init ()
| Initialize thread pool creation.
static MStatus | newParallelRegion (MThreadCallbackFunc func, void *data)
| Creates a new parallel region.
static MStatus | createTask (MThreadFunc func, void *data, MThreadRootTask *root)
| Add a single task to the parallel region.
static MStatus | executeAndJoin (MThreadRootTask *root)
| Run all tasks in the present parallel region to completion.
static void | release ()
| Release decreases the reference count on the thread pool.
static const char * | className ()
| Returns the name of this class.

## Member Function Documentation

MStatus init | ( |  | ) | `[static]`

Search for all occurrences

Initialize thread pool creation.

No threads are created by this call.

Returns:
  - MS::kSuccess The method was successful.
  - MS::kInsufficientMemory Insufficient memory to complete this method

Examples:
  threadTestCmd.cpp, and threadTestWithLocksCmd.cpp.

MStatus newParallelRegion | ( | MThreadCallbackFunc | func,
|  | void * | data
| ) |  | `[static]`

Search for all occurrences

Creates a new parallel region.

All tasks created by createTask() will be added to this region. init() must be called to create the thread pool before calling this function.

Parameters:

  [in] | func | pointer to function to be executed by threads
  [in] | data | data for function

Returns:
  - MS::kSuccess The method was successful.
  - MS::kFailure Thread pool does not exist

Examples:
  threadTestCmd.cpp, and threadTestWithLocksCmd.cpp.

MStatus createTask | ( | MThreadFunc | func,
|  | void * | data,
|  | MThreadRootTask * | root
| ) |  | `[static]`

Search for all occurrences

Add a single task to the parallel region.

The parallel region must already have been created by calling newParallelRegion.

Parameters:

  [in] | func | pointer to function to be executed by threads
  [in] | data | data for function
  [in] | root | root task

Returns:
  - MS::kSuccess The method was successful.
  - MS::kFailure Thread pool does not exist

Examples:
  threadTestCmd.cpp, and threadTestWithLocksCmd.cpp.

MStatus executeAndJoin | ( | MThreadRootTask * | root | ) | `[static]`

Search for all occurrences

Run all tasks in the present parallel region to completion.

This function must be called from within a function invoked by the method newParallelRegion.

Parameters:

  [in] | root | task to execute

Returns:
  - MS::kSuccess The method was successful.
  - MS::kFailure Thread pool does not exist

Examples:
  threadTestCmd.cpp, and threadTestWithLocksCmd.cpp.

void release | ( |  | ) | `[static]`

Search for all occurrences

Release decreases the reference count on the thread pool.

When the reference count reaches zero the thread pool is deleted.

Examples:
  threadTestCmd.cpp, and threadTestWithLocksCmd.cpp.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool
MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool MThreadPool