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

# globus\_thread\_once(3)

One-time execution - One-time execution.

## NAME

globus\_thread\_once - One-time execution

 \- One-time execution.

## SYNOPSIS

### Data Structures

union **globus\_thread\_once\_t**\
 Thread once structure.

### Macros

\#define **GLOBUS\_THREAD\_ONCE\_INIT**\
 Thread once initializer value.

### Functions

int **globus\_thread\_once** (**globus\_thread\_once\_t** \*once, void(\*init\_routine)(void))\
 Execute a function one time.

## Detailed Description

One-time execution.

The **globus\_thread\_once\_t** provides a way for applications and libraries to execute some code exactly one time, independent of the number of threads which attempt to execute it. To use this, statically initialize a **globus\_thread\_once\_t** control with the value GLOBUS\_THREAD\_ONCE\_INIT, and pass a pointer to a function to execute once, along with the control, to **globus\_thread\_once()**.

## Function Documentation

### int globus\_thread\_once (globus\_thread\_once\_t \* once, void(\*)(void) init\_routine)

Execute a function one time. The **globus\_thread\_once()** function will execute the function pointed to by its *init\_routine* parameter one time for each unique **globus\_thread\_once\_t** object passed to it, independent of the number of threads calling it. The *once* value must be a static value initialized to GLOBUS\_THREAD\_ONCE\_INIT.

**Parameters**

*once* A pointer to the value used to govern whether the function passed via the *init\_routine* parameter has executed. \
 *init\_routine* Function to execute one time. It is called with no parameters.

**Returns**

On success, **globus\_thread\_once()** guarantees that the function pointed to by *init\_routine* has run, and that subsequent calls to **globus\_thread\_once()** with the same value of *once* will not execute that function, and returns GLOBUS\_SUCCESS. If an error occurs, **globus\_thread\_once()** returns an implementation-specific non-zero error value.

## Author

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