CVL’s Threading Interface

The table below briefly describes the CVL classes and functions used for multithreading.

CVL Interface for multithreading

Class or function

Notes

cfCreateThreadCVL()

Starts a new non-MFC thread at a specified priority. Any resources allocated internally by CVL for this thread are cleaned up automatically when the thread exits. Use this function for non-MFC applications.

cfCreateThreadMFC()

Starts a new MFC thread at a specified priority. Any resources allocated internally by CVL for this thread are cleaned up automatically when the thread exits. Use this function for MFC applications, or if you will be using any CVL component (such as ccDisplayConsole) that uses MFC.

cfThreadCleanup()

Must be called at the termination of all threads that call CVL functions and were not created using cfCreateThreadCVL() or cfCreateThreadMFC().

cc_Resource

Base class for ccMutex, ccSemaphore, and ccEvent. The cc_Resource::breakLocks() method can be used to release a thread you are about to terminate.

ccMutex

A resource that can be locked one or more times by a single thread.

ccSemaphore

A resource that can be locked by one or more threads, up to a specified count.

ccEvent

A resource that describes an event. An event can have two states, set and reset. A thread that locks the event can change its state. One or more threads can block while waiting for an event’s state to change from reset to set.

ccLock

Sets a lock on a mutex, semaphore, or event. Destructor automatically unlocks, so unlocking is assured.

ccCriticalSection

An object that may be owned by only one thread of execution at a time. Critical sections are a lightweight, faster equivalent of mutexes.

ccCriticalSectionLock

Sets a lock on a critical section. Destructor automatically unlocks, so unlocking is assured.

ccThreadID

Platform‑independent thread identifier.

ccThreadLocal

A parameterized class that allocates thread-safe global storage at static initialization time.

cfSetThreadPriority(),
cfGetThreadPriority(),
cfGetCurrentThreadID()

Functions for manipulating thread priority and getting a thread ID.

cfWaitForThreadTermination()

Blocks execution until a specific thread terminates.