Indy 9 | Content | Index | Reference

TIdSync
Hierarchy, Properties, Methods, See Also, Unit: IdSync
Specifies a mechanism for thread-based notification messages and synchronize method calls.

    TIdSync = class(TObject)

Unit
IdSync
Description
TIdSync is a TObject descendant that implements support for abstract Synchronized methods calls that have parameters and/or return values. TIdSync also provides methods that support thread-based notification messages to reduce overhead in server applications.

TIdSync is used to act in behalf of the Indy thread instance specified in Thread, and also insures that at least a single instance of the Thread class has been created in the application.

An instance of TIdSync is used when TIdThread calls Notify, and is added to the global thread-based notifcation mechanism in GNotifyThread. GNotifyThread is used instead of PostMessage because of changes to the Synchronize method calls in Delphi 6 and Kylix, and also provides a low overhead notification mechanism for server applications.

TIdSync.Thread
TIdSync, See Also
Represents the thread of execution to Syncronized or Notified.

    property Thread: TIdBaseThread;

Description
Thread is a read-only TIdThread property that represents an Indy thread that can receive the notification and synchronization provided by the TIdSync object instance. Thread is the recipient of any redirected Notify or Synchronize method calls received by TIdSync.

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

    constructor Create; virtual; overload;

Parameters
AThread
Indy Thread to receive the notify or synchronize message.
Description
Create is the constructor for the object instance, and calls the inherited Create method to initiailize properties in the object. Create sets Thread to the Indy thread class instance specified in AThread.

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

    constructor Create(AThread: TIdBaseThread); virtual; overload;

Parameters
AThread: TIdBaseThread
Indy Thread to receive the notify or synchronize message.
Description
Create is the constructor for the object instance, and calls the inherited Create method to initiailize properties in the object. Create sets Thread to the Indy thread class instance specified in AThread.

TIdSync.DoSynchronize
TIdSync, See Also
Specifices the mechanism for implementing a synchronized method.

    procedure DoSynchronize; virtual; abstract;

Description
DoSynchronize is an abstract virtual procedure in TIdSync, and specifies the mechanism to be used for implementing a method call that must be executed using the main VCL thread to avoid multi-threading conflicts. DoSynchronize is the method used when the object instance calls Synchronize.

Note: TIdSync provides synchronization and notification for threads. Descendant classes should override the DoSynchronize method to implement support for thread methods, or methods with parameters and/or return values.

TIdSync.Synchronize
TIdSync, See Also
Perform Synchronization for a thread instead of a thread method.

    procedure Synchronize;

Description
Synchronize is a procedure used to avoid conflicts in a multi-threaded application. Synchronize allows Thread to call its Synchronize with the abstract virtual DoSynchronize method. The net result is that the instance in Thread receives a Notify message, and subsequently is executed, without a realized call to a ThreadMethod.

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