Indy 9 | Content | Index | Reference

TIdThreadSafeStringList
Hierarchy, Methods, See Also, Unit: IdThreadSafe
Implements a thread-safe TStringList data type.

    TIdThreadSafeStringList = class(TIdThreadSafe)

Unit
IdThreadSafe
Description
TIdThreadSafeStringList is a TIdThreadSafe descendant that implements a thread-safe data type for storing TStringList values. TIdThreadSafeStringList relies on the inherited TCriticalSection for resource protection in multi-threaded applications. TIdThreadSafeStringList implements procedures and functions that provide read and write access to the values in the internal TStringList with resource protection.

Use Lock to acquire a protected copy of the resource-protected TStringList, and Unlock to release the resource-protected value. Note: Access to values in the instance are blocked to other threads until Unlock is called.

Use Add or AddObject to add a new value(s) to the resource-protected TStringList.

Use ObjectByItem to retrieve an Object in the resource-protected TStringList using the associated String value.

Use Clear to remove all values in the resource-protected TStringList.

Use Remove to locate and delete a value in the resource-protected TStringList using the associated String value.

TIdThreadSafeStringList.Add
TIdThreadSafeStringList, See Also
Adds a string value to the thread-safe data type.

    procedure Add(const AItem: string);

Parameters
const AItem: string
String value added to the data type.
Description
Add is a procedure used to add the String value in AItem to the Value for the thread-safe TStringList data type. Add calls Lock to enable resource protection for Value prior to adding the contents of AItem to the thread-safe data type. Adds calls Unlock to disable resource protection for Value when AItem has been added, or an exception is raised.

Use AddObject to add a string with an associated TObject instance to the thread-safe data type.

Use Remove or Clear to delete one or all items in the thread-safe data type.

TIdThreadSafeStringList.AddObject
TIdThreadSafeStringList, See Also
Adds a string value and an associated object instance to the thread-safe data type.

    procedure AddObject(const AItem: string; AObject: TObject);

Parameters
const AItem: string
String value added to the data type.
AObject: TObject
Object instance added to the data type.
Description
AddObject is a procedure used to add the String in AItem and the TObject instance in AObject to the items in Value for the thread-safe TStringList data type. AddObject calls Lock to enable resource protection for Value prior to adding the item and object to the thread-safe data type. Adds calls Unlock to disable resource protection for Value when the item and onbject have been added, or an exception is raised.

Use Add to add a string to the items in the thread-safe data type.

Use Remove or Clear to delete one or all items in the thread-safe data type.

TIdThreadSafeStringList.Clear
TIdThreadSafeStringList, See Also
Deletes all items in the thread-safe data type.

    procedure Clear;

Description
Clear is a procedure used to remove all items in Value for the thread-safe TStringList data type. Clear calls Lock to enable resource protection for Value prior to removing items in Value for the thread-safe data type. Clear calls Unlock to disable resource protection for Value when items in Value have been deleted, or an exception is raised.

Use Remove to delete a single item in Value from the thread-safe data type.

TIdThreadSafeStringList.Create
TIdThreadSafeStringList, See Also
Constructor for the object instance.

    constructor Create(const ASorted: Boolean = False); reintroduce;

Parameters
const ASorted: Boolean = False
Indicates that items in the data type value are sorted alphabetically.
Description
Create is the constructor for the thread-safe data type object instance. Create calls the inherited Create method prior to allocating the TStringList used in the Value property. Create also sets the Sorted property in Value to the parameter ASorted.

Use Free to release the thread-safe data type object instance.

TIdThreadSafeStringList.Destroy
TIdThreadSafeStringList, See Also
Frees the thread-safe data type.

    destructor Destroy; override;

Description
Destroy is the destructor for the thread-safe data type object instance. Destroy calls Lock to enable resource protection while resources allocated to Value in the Create method are freed. Destroy call Unlock to disable resource protection on successful completion, or when an exception is raised. The inherited Destroy method is called prior to exit.

TIdThreadSafeStringList.Lock
TIdThreadSafeStringList, See Also
Enables resource protection and returns the current value for the thread-safe data type.

    function Lock: TStringList; reintroduce;

Return Value
TStringList - Contents of the Value for the data type.
Description
Lock is a TStringList function used enable resource protection for the thread-safe data type, and return the current contents of Value. Lock is re-introduced in TIdThreadSafeStringList to provide the TStringList return value for the data type. Lock calls the inherited Lock method, and sets the return value to Value.

Use Unlock to disable the resource protection capabilities of the thread-safe data type.

TIdThreadSafeStringList.ObjectByItem
TIdThreadSafeStringList, See Also
Retrieves an object instance by an associated item value.

    function ObjectByItem(const AItem: string): TObject;

Parameters
const AItem: string
Value in Items used to locate the object instance.
Return Value
TObject - Object instance associated with the item value, or Nil.
Description
ObjectByItem is a TObject function used to retrieve an object instance from the thread-safe data type using the associated item value specified in AItem. ObjectByItem calls Lock to enable resource protection while items in Value are searched using it's IndexOf method. The return value for the method is Nil when AItem cannot be found in the item values in Value. ObjectByItem call Unlock to disable resource protection on successful completion, or when an exception is raised.

TIdThreadSafeStringList.Remove
TIdThreadSafeStringList, See Also
Deletes a string value from the items in the thread-safe data type.

    procedure Remove(const AItem: string);

Parameters
const AItem: string
String value to remove from the data type.
Description
Remove is a procedure used to delete the String value in AItem from the Value for the thread-safe TStringList data type. Remove calls Lock to enable resource protection for Value prior to searching Value using it's IndedxOf method. When AItems exists in Value, it is deleted. Remove calls Unlock to disable resource protection for Value when AItem has been deleted, or an exception is raised.

Use Add to add a string value to the thread-safe data type.

Use AddObject to add a string with an associated TObject instance to the thread-safe data type.

Use Clear to delete all items in the thread-safe data type.

TIdThreadSafeStringList.Unlock
TIdThreadSafeStringList, See Also
Disables resource protection for the associated data type.

    procedure Unlock; reintroduce;

Description
Unlock is a procedure used to disengage the resource protection capabilities of the class for the associated data type. Unlock calls the inherited method that 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.