Skip to content

Threads and Condition Variables

Functions

Name
int wolfSSL_NewThread(THREAD_TYPE * thread, THREAD_CB cb, void * arg)
Creates a new thread.
int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void * arg)
Creates a detached thread.
int wolfSSL_JoinThread(THREAD_TYPE thread)
Waits for thread to complete.
int wolfSSL_CondInit(COND_TYPE * cond)
Initializes condition variable.
int wolfSSL_CondFree(COND_TYPE * cond)
Frees condition variable.
int wolfSSL_CondSignal(COND_TYPE * cond)
Signals condition variable.
int wolfSSL_CondWait(COND_TYPE * cond)
Waits on condition variable.
int wolfSSL_CondStart(COND_TYPE * cond)
Starts condition variable.
int wolfSSL_CondEnd(COND_TYPE * cond)
Ends condition variable.

Functions Documentation

function wolfSSL_NewThread

int wolfSSL_NewThread(
    THREAD_TYPE * thread,
    THREAD_CB cb,
    void * arg
)

Creates a new thread.

Parameters:

  • thread Thread handle pointer
  • cb Thread callback function
  • arg Argument to pass to callback

See: wolfSSL_JoinThread

Return:

  • 0 on success
  • negative on error

On Zephyr the thread object and its stack are allocated with the global heap hint wolfsslThreadHeapHint and freed with it in wolfSSL_JoinThread. Set the hint before the first call to wolfSSL_NewThread. It must not be changed once it has been used for an allocation: memory would be freed to the wrong heap.

Example

THREAD_TYPE thread;
int ret = wolfSSL_NewThread(&thread, myCallback, NULL);

function wolfSSL_NewThreadNoJoin

int wolfSSL_NewThreadNoJoin(
    THREAD_CB_NOJOIN cb,
    void * arg
)

Creates a detached thread.

Parameters:

  • cb Thread callback function
  • arg Argument to pass to callback

See: wolfSSL_NewThread

Return:

  • 0 on success
  • negative on error

Example

int ret = wolfSSL_NewThreadNoJoin(myCallback, NULL);

function wolfSSL_JoinThread

int wolfSSL_JoinThread(
    THREAD_TYPE thread
)

Waits for thread to complete.

Parameters:

  • thread Thread handle

See: wolfSSL_NewThread

Return:

  • 0 on success
  • negative on error

Example

THREAD_TYPE thread;
wolfSSL_NewThread(&thread, myCallback, NULL);
int ret = wolfSSL_JoinThread(thread);

function wolfSSL_CondInit

int wolfSSL_CondInit(
    COND_TYPE * cond
)

Initializes condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondFree

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
int ret = wolfSSL_CondInit(&cond);

function wolfSSL_CondFree

int wolfSSL_CondFree(
    COND_TYPE * cond
)

Frees condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondInit

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
wolfSSL_CondInit(&cond);
int ret = wolfSSL_CondFree(&cond);

function wolfSSL_CondSignal

int wolfSSL_CondSignal(
    COND_TYPE * cond
)

Signals condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondWait

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
int ret = wolfSSL_CondSignal(&cond);

function wolfSSL_CondWait

int wolfSSL_CondWait(
    COND_TYPE * cond
)

Waits on condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondSignal

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
int ret = wolfSSL_CondWait(&cond);

function wolfSSL_CondStart

int wolfSSL_CondStart(
    COND_TYPE * cond
)

Starts condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondEnd

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
int ret = wolfSSL_CondStart(&cond);

function wolfSSL_CondEnd

int wolfSSL_CondEnd(
    COND_TYPE * cond
)

Ends condition variable.

Parameters:

  • cond Condition variable pointer

See: wolfSSL_CondStart

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;
wolfSSL_CondStart(&cond);
int ret = wolfSSL_CondEnd(&cond);

Updated on 2026-11-26 at 01:16:21 +0000