---
name: "globus_cond"
section: "3"
platform: "linux"
package: "libglobus-common-doc"
version: "18.14-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/globus_cond"
---

# globus\_cond(3)

Condition Variables - Condition Variables.

## NAME

globus\_cond - Condition Variables

 \- Condition Variables.

## SYNOPSIS

### Data Structures

union **globus\_cond\_t**\
 Condition variable.  union **globus\_condattr\_t**\
 Condition variable attribute.

### Functions

int **globus\_cond\_init** (**globus\_cond\_t** \*cond, **globus\_condattr\_t** \*attr)\
 Initialize a condition variable

The **globus\_cond\_init()** function creates a condition variable that can be used for event signalling between threads. " int **globus\_cond\_destroy** (**globus\_cond\_t** \*cond)\
 Destroy a condition variable.  int **globus\_cond\_wait** (**globus\_cond\_t** \*cond, **globus\_mutex\_t** \*mutex)\
 Wait for a condition to be signalled.  int **globus\_cond\_timedwait** (**globus\_cond\_t** \*cond, **globus\_mutex\_t** \*mutex, globus\_abstime\_t \*abstime)\
 Wait for a condition to be signalled.  int **globus\_cond\_signal** (**globus\_cond\_t** \*cond)\
 Signal a condition to a thread.  int **globus\_cond\_broadcast** (**globus\_cond\_t** \*cond)\
 Signal a condition to multiple threads.  int **globus\_condattr\_init** (**globus\_condattr\_t** \*cond\_attr)\
 Initialize a condition variable attribute.  int **globus\_condattr\_destroy** (**globus\_condattr\_t** \*cond\_attr)\
 Destroy a condition attribute.  int **globus\_condattr\_setspace** (**globus\_condattr\_t** \*cond\_attr, int space)\
 Set callback space associated with a condition variable attribute

The **globus\_condattr\_setspace()** function sets the callback space to use with condition variables created with this attribute. Callback spaces are used to control how callbacks are issued to different threads. See **Callback Spaces**  for more information on callback spaces. " int **globus\_condattr\_getspace** (**globus\_condattr\_t** \*cond\_attr, int \*space)\
 Get callback space associated with a condition variable attribute

The **globus\_condattr\_getspace()** function copies the value of the callback space associated with a condition variable attribute to the integer pointed to by the *space* parameter. "

## Detailed Description

Condition Variables.

The **globus\_cond\_t** provides condition variables for signalling events between threads interested in particular state. One or many threads may wait on a condition variable until it is signalled, at which point they can attempt to lock a mutex related to that condition's state and process the event.

In a non-threaded model, the condition variable wait operations are used to poll the event driver to handle any operations that have been scheduled for execution by the globus\_callback system or I/O system. In this way, applications written to use those systems to handle nonblocking operations will work with either a threaded or nonthreaded runtime choice.

## Function Documentation

### int globus\_cond\_broadcast (globus\_cond\_t \* cond)

Signal a condition to multiple threads. The **globus\_cond\_signal()** function signals a condition as occurring. This will unblock all threads waiting for that condition.

**Parameters**

*cond* A pointer to the condition variable to signal.

**Returns**

Upon success, **globus\_cond\_broadcast()** returns GLOBUS\_SUCCESS. If an error occurs, **globus\_cond\_broadcast()** returns an implementation-specific non-zero error code.

### int globus\_cond\_destroy (globus\_cond\_t \* cond)

Destroy a condition variable. The **globus\_cond\_destroy()** function destroys the condition variable pointed to by its *cond* parameter. After a condition variable is destroyed it may no longer be used unless it is again initialized by **globus\_cond\_init()**.

**Parameters**

*cond* The condition variable to destroy.

**Returns**

On success, **globus\_cond\_destroy()** returns GLOBUS\_SUCCESS. Otherwise, a non-zero implementation-specific error value is returned.

### int globus\_cond\_init (globus\_cond\_t \* cond, globus\_condattr\_t \* attr)

Initialize a condition variable

The **globus\_cond\_init()** function creates a condition variable that can be used for event signalling between threads.

**Parameters**

*cond* Pointer to the condition variable to initialize. \
 *attr* Condition variable attributes.

**Returns**

On success, **globus\_cond\_init()** initializes the condition variable and returns GLOBUS\_SUCCESS. Otherwise, a non-0 value is returned.

### int globus\_cond\_signal (globus\_cond\_t \* cond)

Signal a condition to a thread. The **globus\_cond\_signal()** function signals a condition as occurring. This will unblock at least one thread waiting for that condition.

**Parameters**

*cond* A pointer to the condition variable to signal.

**Returns**

Upon success, **globus\_cond\_signal()** returns GLOBUS\_SUCCESS. If an error occurs, **globus\_cond\_signal()** returns an implementation-specific non-zero error code.

### int globus\_cond\_timedwait (globus\_cond\_t \* cond, globus\_mutex\_t \* mutex, globus\_abstime\_t \* abstime)

Wait for a condition to be signalled. The **globus\_cond\_timedwait()** function atomically unlocks the mutex pointed to by the *mutex* parameter and blocks the current thread until either the condition variable pointed to by *cond* is signalled by another thread or the current time exceeds the value pointed to by the *abstime* parameter. If the timeout occurs before the condition is signalled, **globus\_cond\_timedwait()** returns ETIMEDOUT. Behavior is undefined if **globus\_cond\_timedwait()** is called with the mutex pointed to by the *mutex* variable unlocked.

**Parameters**

*cond* The condition variable to wait for. \
 *mutex* The mutex associated with the condition state. \
 *abstime* The absolute time to wait until.

**Returns**

On success, **globus\_cond\_timedwait()** unlocks the mutex and blocks the current thread until it has been signalled, returning GLOBUS\_SUCCES. If a timeout occurs before signal, **globus\_cond\_timedwait()** unlocks the mutex and returns ETIMEDOUT. Otherwise, **globus\_cond\_timedwait()** returns an implementation-specific non-zero error value.

### int globus\_cond\_wait (globus\_cond\_t \* cond, globus\_mutex\_t \* mutex)

Wait for a condition to be signalled. The **globus\_cond\_wait()** function atomically unlocks the mutex pointed to by the *mutex* parameter and blocks the current thread until the condition variable pointed to by *cond* is signalled by either **globus\_cond\_signal()** or **globus\_cond\_broadcast()**. Behavior is undefined if **globus\_cond\_wait()** is called with the mutex pointed to by the *mutex* variable unlocked.

**Parameters**

*cond* The condition variable to wait for. \
 *mutex* The mutex associated with the condition state.

**Returns**

On success, **globus\_cond\_wait()** unlocks the mutex and blocks the current thread until it has been signalled, returning GLOBUS\_SUCCES. Otherwise, **globus\_cond\_wait()** returns an implementation-specific non-zero error value.

### int globus\_condattr\_destroy (globus\_condattr\_t \* cond\_attr)

Destroy a condition attribute. The **globus\_condattr\_destroy()** function destroys the condition variable attribute structure pointed to by its *cond\_attr* parameter.

**Parameters**

*cond\_attr* Attribute structure to destroy.

**Returns**

Upon success, **globus\_condattr\_destroy()** returns GLOBUS\_SUCCESS and modifies the attribute pointed to by *cond\_attr*. If an error occurs, **globus\_condattr\_destroy()** returns an implementation-specific non-zero error code.

### int globus\_condattr\_getspace (globus\_condattr\_t \* cond\_attr, int \* space)

Get callback space associated with a condition variable attribute

The **globus\_condattr\_getspace()** function copies the value of the callback space associated with a condition variable attribute to the integer pointed to by the *space* parameter.

**Parameters**

*cond\_attr* Condition variable attribute to modify. \
 *space* Pointer to an integer to be set to point to the callback space associated with cond\_attr.

**Returns**

On success, **globus\_condattr\_getspace()** returns GLOBUS\_SUCCESS and modifies the value pointed to by *space* to refer to the callback space associated with *cond\_attr*. If an error occurs, **globus\_condattr\_getspace()** returns an implementation-specific non-zero error code.

### int globus\_condattr\_init (globus\_condattr\_t \* cond\_attr)

Initialize a condition variable attribute. The **globus\_condattr\_init()** function initializes the condition variable attribute structure pointed to by its *cond\_attr* parameter to the system default values.

**Parameters**

*cond\_attr* Attribute structure to initialize.

**Returns**

Upon success, **globus\_condattr\_init()** returns GLOBUS\_SUCCESS and modifies the attribute pointed to by *cond\_attr*. If an error occurs, **globus\_condattr\_init()** returns an implementation-specific non-zero error code.

### int globus\_condattr\_setspace (globus\_condattr\_t \* cond\_attr, int space)

Set callback space associated with a condition variable attribute

The **globus\_condattr\_setspace()** function sets the callback space to use with condition variables created with this attribute. Callback spaces are used to control how callbacks are issued to different threads. See **Callback Spaces**  for more information on callback spaces.

**Parameters**

*cond\_attr* Condition variable attribute to modify. \
 *space* Callback space to associate with the attribute.

**Returns**

On success, **globus\_condattr\_setspace()** returns GLOBUS\_SUCCESS and adds a reference to the callback space to the condition variable attribute. If an error occurs, **globus\_condattr\_setspace()** returns an implementation-specific non-zero error code.

## Author

Generated automatically by Doxygen for globus\_common from the source code.
