TCriticalSection class
Critical section.
Declaration
TCriticalSection = class(TSynchroObject)Inheritance
- TCriticalSection
- TSynchroObject
- TObject
Descends from it: TLazMonitor
Description
TCriticalSection is a class wrapper around the low-level
TRTLCriticalSection routines. It simply calls the RTL routines
in the system unit for critical section support.
A critical section is a resource which can be owned by only 1 caller: it can be used to make sure that in a multithreaded application only 1 thread enters pieces of code protected by the critical section.
Typical usage is to protect a piece of code with the following code
(MySection is a TCriticalSection instance):
// Previous code
MySection.Acquire;
Try
// Protected code
Finally
MySection.Release;
end;
// Other code.
The protected code can be executed by only 1 thread at a time. This is useful for instance for list operations in multithreaded environments.
See also
Methods
Acquire | public | Enter the critical section. |
Release | public | Leave the critical section. |
WaitFor | public | |
Enter | public | Alias for Acquire. |
TryEnter | public | Try and obtain the critical section. |
Leave | public | Alias for Release. |
Create | public | Create a new critical section. |
Destroy | public | Destroy the criticalsection instance. |
Inherited
From TObject (40)
AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
