RTEMS  5.1
Files | Functions
Once Functions.

The _Once() function for pthread_once() and rtems_gxx_once(). More...

Files

file  onceimpl.h
 Once API.
 

Functions

int _Once (unsigned char *once_state, void(*init_routine)(void))
 Reacts according to the state of once_state. More...
 
Thread_Life_state _Once_Lock (void)
 Locks the Once_Information_Mutex and returns the thread life state. More...
 
void _Once_Unlock (Thread_Life_state thread_life_state)
 Unlocks the Once_Information_Mutex and sets the thread life protection to thread_life_state. More...
 

Detailed Description

The _Once() function for pthread_once() and rtems_gxx_once().

Function Documentation

◆ _Once()

int _Once ( unsigned char *  once_state,
void(*)(void)  init_routine 
)

Reacts according to the state of once_state.

If once_state is ONCE_STATE_INIT, then the once state is set first to ONCE_STATE_RUNNING and after calling the init routine it is set to ONCE_STATE_COMPLETED. If once_state is ONCE_STATE_COMPLETED, nothing happens. If once_state is not either one, this method waits for the Once_Information_Mutex.

Parameters
once_stateThe once state.
init_routineThe initialization routine called if once_state is ONCE_STATE_INIT.
Returns
This method always returns zero upon termination.

◆ _Once_Lock()

Thread_Life_state _Once_Lock ( void  )

Locks the Once_Information_Mutex and returns the thread life state.

Returns
The thread life state (THREAD_LIFE_PROTECTED).

◆ _Once_Unlock()

void _Once_Unlock ( Thread_Life_state  thread_life_state)

Unlocks the Once_Information_Mutex and sets the thread life protection to thread_life_state.

Parameters
thread_life_stateThe thread life state to set the thread life protection to.