Name

cgSetLockingPolicy - set locking policy

Synopsis

#include <Cg/cg.h>

CGenum cgSetLockingPolicy( CGenum lockingPolicy );

Parameters

lockingPolicy
An enumerant describing the desired locking policy for the library. The following enumerants are allowed:
CG_THREAD_SAFE_POLICY
Locks will be used to serialize thread access to the library.
CG_NO_LOCKS_POLICY
Locks will not be used.

Return Values

Returns the previous locking policy, or CG_UNKNOWN if an error occurs.

Description

cgSetLockingPolicy allows an application to change the locking policy used by the Cg library. The default policy is CG_THREAD_SAFE_POLICY, meaning a lock is used to serialize access to the library by mulitiple threads. Single threaded applications can change this policy to CG_NO_LOCKS_POLICY to avoid the overhead associated with this lock. Multithreaded applications should never change this policy.

Examples

/* multithreaded apps should *never* do this */
cgSetLockingPolicy(CG_NO_LOCKS_POLICY);

Errors

CG_INVALID_ENUMERANT_ERROR is generated if lockingPolicy is not CG_NO_LOCKS_POLICY or CG_THREAD_SAFE_POLICY.

History

cgSetLockingPolicy was introduced in Cg 2.0.

See Also

cgGetLockingPolicy