System.TMonitor
Delphi
TMonitor = record
C++
struct DECLSPEC_DRECORD TMonitor
{
private:
    struct TWaitingThread;
    typedef TWaitingThread *PWaitingThread;
    struct DECLSPEC_DRECORD TWaitingThread
    {
    public:
        TMonitor::PWaitingThread Next;
        TThreadID Thread;
        void *WaitEvent;
    };
    struct DECLSPEC_DRECORD TSpinWait
    {
    private:
        static _DELPHI_CONST System::Int8 YieldThreshold = System::Int8(0xa);
        static _DELPHI_CONST System::Int8 Sleep1Threshold = System::Int8(0x14);
        static _DELPHI_CONST System::Int8 Sleep0Threshold = System::Int8(0x5);
        int FCount;
    public:
        void __fastcall Reset();
        void __fastcall SpinCycle();
    };
    struct DECLSPEC_DRECORD TSpinLock
    {
    private:
        int FLock;
    public:
        void __fastcall Enter();
        void __fastcall Exit();
    };
private:
    int FLockCount;
    int FRecursionCount;
    TThreadID FOwningThread;
    void *FLockEvent;
    int FSpinCount;
    PWaitingThread FWaitQueue;
    TSpinLock FQueueLock;
    static int CacheLineSize;
    static int FDefaultSpinCount;
    static void __fastcall Spin(int Iterations);
    static int __fastcall GetCacheLineSize();
    void __fastcall QueueWaiter(TWaitingThread &WaitingThread);
    void __fastcall RemoveWaiter(TWaitingThread &WaitingThread);
    PWaitingThread __fastcall DequeueWaiter();
    void * __fastcall GetEvent();
    TThreadID __fastcall CheckOwningThread();
    static void __fastcall CheckMonitorSupport();
private:
    static PMonitor __fastcall Create();
    static void __fastcall Destroy(TObject* const AObject)/* overload */;
    void __fastcall Destroy()/* overload */;
private:
    static PPMonitor __fastcall GetFieldAddress(TObject* const AObject);
    static PMonitor __fastcall GetMonitor(TObject* const AObject);
    static void __fastcall SetDefaultSpinCount(int AValue);
    bool __fastcall TryEnter()/* overload */;
    bool __fastcall Wait(PMonitor ALock, unsigned Timeout)/* overload */;
    void __fastcall Pulse()/* overload */;
    void __fastcall PulseAll()/* overload */;
private:
    bool __fastcall Enter(unsigned Timeout)/* overload */;
    void __fastcall Exit()/* overload */;
public:
    static void __fastcall SetSpinCount(TObject* const AObject, int ASpinCount);
    static void __fastcall Enter(TObject* const AObject)/* overload */;
    static bool __fastcall Enter(TObject* const AObject, unsigned Timeout)/* overload */;
    static void __fastcall Exit(TObject* const AObject)/* overload */;
    static bool __fastcall TryEnter(TObject* const AObject)/* overload */;
    static bool __fastcall Wait(TObject* const AObject, unsigned Timeout)/* overload */;
    static bool __fastcall Wait(TObject* const AObject, TObject* const ALock, unsigned Timeout)/* overload */;
    static void __fastcall Pulse(TObject* const AObject)/* overload */;
    static void __fastcall PulseAll(TObject* const AObject)/* overload */;
    /* static */ __property int DefaultSpinCount = {read=FDefaultSpinCount, write=SetDefaultSpinCount};
};
Properties
| Type | Visibility | Source | Unit | Parent | 
|---|---|---|---|---|
record struct  | 
		public | System.pas System.hpp  | 
        System | System | 
Description
TMonitor provides methods for synchronizing the access of several threads to a single object.
Use the class methods of TMonitor to synchronize the threads' access to resources in a multithreaded application.
See Also