ThreadCmd Class

Namespace: id3.Devices

Definition

(C++) Represents a thread command in C/C++ environments, equipped with callback mechanisms for worker, command, and process operations, alongside methods for detailed thread management.
typedef struct id3DevicesThreadCmd *ID3_DEVICES_THREAD_CMD;

Usage

ID3_DEVICES_THREAD_CMD hThreadCmd{};
int err = id3DevicesThreadCmd_Initialize(&hThreadCmd);
if (err == ID3_SUCCESS) {
    // ...
    id3DevicesThreadCmd_Dispose(&hThreadCmd);
}

Properties

Name

Type

Description

commandCallback

ThreadCommandCallback

Defines the callback for executing specific commands within the thread, allowing for dynamic command processing.

processCallback

ThreadProcessCallback

Sets the process callback, responsible for handling more complex processing tasks that might be queued within the thread.

workerCallback

ThreadWorkerCallback

Specifies the main worker thread callback, handling the primary tasks assigned to the thread.

Methods

Name

Description

getCmdSemaphore

Accesses the semaphore controlling command execution, allowing for the synchronization of command processing.

getLoopFlag

Retrieves the status of the thread’s loop flag, indicating whether the thread is in a continuous operation mode.

getStopEvent

Obtains the event used to signal the thread to stop, facilitating external control over thread termination.

processFifoCmd

Processes commands queued in the FIFO, taking a generic argument for command-specific data.

sendCmd

Dispatches a simple command to be executed by the thread, identified by an integer index.

sendCmdBuffer

Sends a command along with a data buffer, optionally specifying if the buffer should be released after execution.

sendCmdParam

Sends a command accompanied by up to three integer parameters, providing detailed instruction for command execution.

sendCmdWithEvent

Issues a command that triggers an event upon completion, supporting synchronization with other thread activities.

setCommandFifoSize

Configures the size of the command queue, determining how many commands can be queued before processing.

setThreadPriority

Alters the thread’s priority, influencing its execution order relative to other system threads.

setThreadWorkerWait

Adjusts the worker thread’s wait time, optimizing thread responsiveness or conserving resources.

startThread

Initiates the thread, starting its execution cycle and enabling it to process tasks.

stopThread

Safely stops the thread, with an optional timeout to ensure the thread does not hang indefinitely.

waitForCmdEnded

Waits for a specified command to complete, offering mechanisms to poll command status and apply a timeout.