Indy 9
TIdThreadSafe
Hierarchy, Methods, See Also, Unit: IdThreadSafe
Implements the ancestor for thread-safe data types.
TIdThreadSafe = class
Unit
IdThreadSafe
Description
TIdThreadSafe is a TObject descendant that represents the base class for thread-safe data types in Indy applications. TIdThreadSafe uses a protected TCriticalSection to provide resource protection in multi-threaded applications. TIdThreadSafe also implements the Lock and Unlock methods to access the resource protection block for the data type.

Note: TIdThreadSafe does not implement a specific data type value, and should not be instantiated in an application. Use one of the descendant classes that realizes a data type, such as TIdThreadSafeInteger, TIdThreadSafeString, or TIdThreadSafeStringList.

TIdThreadSafe and descendant classes are used as an alternative to ThreadVars which does not allow runtime initialization and assignment using C++ Builder. TIdThreadSafe is used in IdTunnelSlave.pas to declared UniqueID for use with tunnel slave components.


TIdThreadSafe.Create
TIdThreadSafe, See Also
Constructor for the object instance.
constructor Create; virtual;
Description
Create is the constructor for the object instance. Create calls the inherited Create method, and allocates the protected TCriticalSection used for resource protection.

TIdThreadSafe.Destroy
TIdThreadSafe, See Also
Frees the object instance.
destructor Destroy; override;
Description
Destroy is the destructor for the object instance. Destroy frees and releases resources allocated for the critical section created in the constructor for the object instance, and calls the inherited Destroy method prior to exit.

TIdThreadSafe.Lock
TIdThreadSafe, See Also
Enables resource protection for the associated data type.
procedure Lock;
Description
Lock is a procedure used to engage the resource protection capabilities of the class for the associated data type. Lock executes the TCriticalSection.Enter method to enable the resource protection block. Use Unlock to release the resource protection block for the class instance.

TIdThreadSafe.Unlock
TIdThreadSafe, See Also
Disables resource protection for the associated data type.
procedure Unlock;
Description
Unlock is a procedure used to disengage the resource protection capabilities of the class for the associated data type. Unlock executes the TCriticalSection.Leave method to disable the resource protection block. Use Lock to enable the resource protection block for the class instance.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.