Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
Thread Struct Reference

Detailed Description

A simple thread class.

The thread class makes it possible to design a platform independent system using threads.

#include <ThreadLib.h>

Inheritance diagram for Thread:

Public Member Functions

 Thread ()
 Uninitialized storage; call Thread_constructor before use/destruction. More...
 
 Thread (Thread_Run r, ThreadPriority priority, int stackSize)
 Create a thread. More...
 
 ~Thread ()
 Release platform thread resources (C: Thread_destructor). More...
 
void start ()
 Release the constructed thread to run its entry point once (C: Thread_start). More...
 

Static Public Member Functions

static void sleep (unsigned int milliseconds)
 Delay the calling thread (C: Thread_sleep). More...
 

Constructor & Destructor Documentation

◆ Thread() [1/2]

Thread::Thread ( )

Uninitialized storage; call Thread_constructor before use/destruction.

◆ Thread() [2/2]

Thread::Thread ( Thread_Run  r,
ThreadPriority  priority,
int  stackSize 
)

Create a thread.

Parameters
rRequired entry-point callback invoked after start. Keep the Thread object and callback dependencies alive until execution finishes.
priorityOne of the five ThreadPriority values, mapped by the port.
stackSizeRequested stack allocation in bytes, a positive value large enough for the callback and its libraries. Ports can round up or add overhead; this is not a portable exact stack-size guarantee. Construction creates thread resources but start releases the entry point to run. No failure status is returned; major ports call baFatalE for creation failures. C equivalent: Thread_constructor.

◆ ~Thread()

Thread::~Thread ( )

Release platform thread resources (C: Thread_destructor).

This is not a portable join or cancellation API. Arrange completion before destroying storage used by a running thread.

Member Function Documentation

◆ sleep()

static void Thread::sleep ( unsigned int  milliseconds)
static

Delay the calling thread (C: Thread_sleep).

Parameters
[in]millisecondsRequested delay in milliseconds. Resolution, rounding and zero-delay behavior are platform-specific. Does not release an application mutex; scheduler delays can extend the wait.

◆ start()

void Thread::start ( )

Release the constructed thread to run its entry point once (C: Thread_start).

Call only once; does not wait for completion.