---
name: "wpool.h"
section: "3"
platform: "linux"
package: "libcoin80-doc"
version: "3.1.4~abc9f50-7"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/wpool.h"
---

# wpool.h(3)

## NAME

wpool.h -

## SYNOPSIS

`#include <Inventor/C/basic.h>`\
 `#include <Inventor/C/threads/common.h>`\

### Typedefs

typedef void **cc\_wpool\_f** (void \*)\

### Functions

cc\_wpool \* **cc\_wpool\_construct** (int numworkers)\
 void **cc\_wpool\_destruct** (cc\_wpool \*pool)\
 int **cc\_wpool\_get\_num\_workers** (cc\_wpool \*pool)\
 void **cc\_wpool\_set\_num\_workers** (cc\_wpool \*pool, int newnum)\
 void **cc\_wpool\_wait\_all** (cc\_wpool \*pool)\
 SbBool **cc\_wpool\_try\_begin** (cc\_wpool \*pool, int numworkersneeded)\
 void **cc\_wpool\_begin** (cc\_wpool \*pool, int numworkersneeded)\
 void **cc\_wpool\_start\_worker** (cc\_wpool \*pool, cc\_wpool\_f \*workfunc, void \*closure)\
 void **cc\_wpool\_end** (cc\_wpool \*pool)\

## Function Documentation

### cc\_wpool\* cc\_wpool\_construct (intnumworkers)

Construct worker pool.

### void cc\_wpool\_destruct (cc\_wpool \*pool)

Destruct worker pool. Will wait for all jobs in progress to finish

### int cc\_wpool\_get\_num\_workers (cc\_wpool \*pool)

Returns the number of workers in the pool.

### void cc\_wpool\_set\_num\_workers (cc\_wpool \*pool, intnewnum)

Sets the number of workers in the pool.

### void cc\_wpool\_wait\_all (cc\_wpool \*pool)

Wait for all pool workers to finish working and go into idle state. This method should only be called by the thread controlling the pool. A pool worker should not call this method, since it will obviously never return from here (it will never go idle).

### SbBool cc\_wpool\_try\_begin (cc\_wpool \*pool, intnumworkersneeded)

Locks the pool so that workers can be started using the **cc\_wpool\_start\_worker()** method. *numworkersneeded* should contain the minumum number of workers that is needed. If  workers are available, the pool will be locked and TRUE is returned. Otherwise FALSE is returned.

Usage pseudocode:

```
int numworkers = 5;
if (cc_wpool_begin(pool, numworkers)) {
  for (int i = 0; i < numworkers; i++) {
    cc_wpool_start_worker(my_work[i], my_closure[i]);
  }
  cc_wpool_end(pool);
}
```

Important! If too few workers are available, the pool will not be locked and **cc\_wpool\_end()** should not be called.

**See also:**

**cc\_wpool\_start\_worker()**, **cc\_wpool\_end()**

### void cc\_wpool\_begin (cc\_wpool \*pool, intnumworkersneeded)

Wait for *numworkersneeded* workers to become idle. When returning from this call, the pool will be locked, and up to *numworkersneeded* can be started using the **cc\_wpool\_start\_worker()** method. Remember to call **cc\_wpool\_end()** to unlock the pool again.

**See also:**

**cc\_wpool\_try\_begin()**

### void cc\_wpool\_start\_worker (cc\_wpool \*pool, cc\_wpool\_f \*workfunc, void \*closure)

Starts a worker. The pool must be locked (using **cc\_wpool\_begin()**) before calling this method.

**See also:**

**cc\_wpool\_begin()** , **cc\_wpool\_end()**

### void cc\_wpool\_end (cc\_wpool \*pool)

Unlocks the pool after a **cc\_wpool\_begin()**, **cc\_wpool\_start\_worker()** sequence.

Please note that if **cc\_wpool\_begin()** returns 0, you should not call **cc\_wpool\_end()**.

**See also:**

**cc\_wpool\_begin()**, **cc\_wpool\_start\_worker()**

## Author

Generated automatically by Doxygen for Coin from the source code.
