topcs.pas
来自「类似fastmm替换Delphi自带的内存管理器」· PAS 代码 · 共 62 行
PAS
62 行
{****************************************************************************************
TOPMEMORY v3.53 - HIGH PERFORMANCE DELPHI MEMORY MANAGER (C) 2008 Ivo Tops, Topsoftware
TopCS is a simple Base for a Class using a critical section and using local memory
****************************************************************************************}
unit TopCS;
interface
{$IFNDEF TOPDEBUG} // Debugging off unless you use the TOPDEBUG directive
{$D-,L-}
{$ENDIF}
{$X+}
uses
Windows,
TopLocalObjects;
type
TCSObject = class(TLocalObject)
private
FCritSect: _RTL_CRITICAL_SECTION;
public
constructor Create; reintroduce;
destructor Destroy; override;
//
procedure Lock; {$IF COMPILERVERSION>=18}inline; {$IFEND}
procedure Unlock; {$IF COMPILERVERSION>=18}inline; {$IFEND}
end;
implementation
constructor TCSObject.Create;
begin
inherited Create;
InitializeCriticalSection(FCritSect);
end;
destructor TCSObject.Destroy;
begin
DeleteCriticalSection(FCritsect);
inherited Destroy;
end;
procedure TCSObject.Lock;
begin
EnterCriticalSection(FCritSect);
end;
procedure TCSObject.unlock;
begin
LeaveCriticalSection(FCritSect);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?