Skip to content

Commit

Permalink
Refractoring, Reformatting and minor Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Warfley committed Feb 18, 2020
1 parent b2945c9 commit 164bb61
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 103 deletions.
4 changes: 2 additions & 2 deletions example.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ TSocketHandler = class(TThreadedWebsocketHandler)

procedure TSocketHandler.MessageRecieved(Sender: TObject);
var
Messages: TMessageOwnerList;
Messages: TWebsocketMessageOwnerList;
m: TWebsocketMessage;
Comm: TWebsocketCommunincator;
begin
Comm := TWebsocketCommunincator(Sender);
Messages := TMessageOwnerList.Create(True);
Messages := TWebsocketMessageOwnerList.Create(True);
try
Comm.GetUnprocessedMessages(Messages);
for m in Messages do
Expand Down
8 changes: 7 additions & 1 deletion utilities.pas
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ TPool = class(specialize TVector<T>);

TPoolableThread = class(TThread)
private
FDoTerminate: boolean;
FIsIdle: boolean;
protected
procedure DoExecute; virtual;
Expand All @@ -53,6 +54,7 @@ TPoolableThread = class(TThread)
const StackSize: SizeUInt = DefaultStackSize);
procedure Restart; virtual;
property isIdle: boolean read FIsIdle;
property DoTerminate: boolean read FDoTerminate write FDoTerminate;
end;

{ TPoolableThreadFactory }
Expand Down Expand Up @@ -403,12 +405,16 @@ procedure TPoolableThread.Execute;
TThread.Yield;
end;
DoExecute;
FIsIdle := True;
if FDoTerminate then
self.Terminate
else
FIsIdle := True;
end;
end;

constructor TPoolableThread.Create(CreateSuspended: boolean; const StackSize: SizeUInt);
begin
FDoTerminate := False;
if CreateSuspended then
FIsIdle := True
else
Expand Down
Loading

0 comments on commit 164bb61

Please sign in to comment.