OSDN Git Service

First created
authornaru <bottle@mikage.to>
Tue, 11 Feb 2003 04:45:22 +0000 (04:45 +0000)
committernaru <bottle@mikage.to>
Tue, 11 Feb 2003 04:45:22 +0000 (04:45 +0000)
bottleclient/BottleSstp.pas [new file with mode: 0755]

diff --git a/bottleclient/BottleSstp.pas b/bottleclient/BottleSstp.pas
new file mode 100755 (executable)
index 0000000..449177f
--- /dev/null
@@ -0,0 +1,71 @@
+unit BottleSstp;
+
+interface
+
+uses Classes, Contnrs, SyncObjs, Windows, Logs;
+
+type
+
+  TBottleSstp = class(TThread)
+  private
+    FCueLock: TCriticalSection;
+    FCue: TObjectList; // \83X\83\8c\83b\83h\83Z\81[\83t\82É\82È\82é\82æ\82¤\82É\92\8d\88Ó
+  public
+    constructor Create(CreateSuspended: boolean);
+    destructor Destroy; override;
+    procedure Push(Bottle: TLogItem);
+    procedure Unshift(Bottle: TLogItem);
+    procedure Execute; override;
+  end;
+
+implementation
+
+{ TBottleSstp }
+
+constructor TBottleSstp.Create(CreateSuspended: boolean);
+begin
+  inherited;
+  FCueLock := TCriticalSection.Create;
+  FCue := TObjectList.Create(true);
+end;
+
+destructor TBottleSstp.Destroy;
+begin
+  FCue.Free;
+  FCueLock.Free;
+  inherited;
+end;
+
+procedure TBottleSstp.Execute;
+begin
+  inherited;
+  while not Terminated do begin
+    sleep(2);
+  end;
+end;
+
+procedure TBottleSstp.Push(Bottle: TLogItem);
+var Item: TLogItem;
+begin
+  Item := TLogItem.Create(Bottle);
+  FCueLock.Enter;
+  try
+    FCue.Add(Item);
+  finally
+    FCueLock.Leave;
+  end;
+end;
+
+procedure TBottleSstp.Unshift(Bottle: TLogItem);
+var Item: TLogItem;
+begin
+  Item := TLogItem.Create(Bottle);
+  FCueLock.Enter;
+  try
+    FCue.Insert(0, Item);
+  finally
+    FCueLock.Leave;
+  end;
+end;
+
+end.