Lucidity
2015-06-17 07:43:15
Is there a difference between the functions :
If so, what are the differences?
wait(100);andsleep(100);If so, what are the differences?
2015-06-17 07:43:15
wait(100);andsleep(100);2015-06-17 08:27:33
2015-06-17 10:11:04
1.“Sleep” is a thread management method that is defined as a static method while “wait” is a thread management method which is defined in the Object class.
2.Sleep is a method that executes threads while wait is a method that executes objects.
3.Sleep keeps the synchronization locks of the current thread and influences the behavior of applications while wait does not.
4.Sleep controls the execution of the thread and does not allow other threads in a synchronized block while wait does not control the execution of the thread to let other threads run.
2015-06-17 11:55:47
From: evilcitrus
…
2015-06-17 12:08:30
procedure Sleep(milliseconds: Cardinal);
begin
{$IFDEF MSWINDOWS}
{$IFDEF FPC}
sysutils.sleep(milliseconds);
{$ELSE}
windows.sleep(milliseconds);
{$ENDIF}
{$ELSE}
sysutils.sleep(milliseconds);
{$ENDIF}
end;2015-06-17 13:15:05
2015-06-17 14:15:33
From: Olly
It's exactly the same… Wait just calls sleep iirc. If you want to know why its there ask who added Wait to scar.
procedure ps_Wait(t: DWord); extdecl;
{$ifdef MSWINDOWS}
begin
Sleep(t);
end;
{$else}
var
EndTime : DWord;
begin
if t > 50 then
begin;
EndTime := GetTickCount + t;
while {(CurrThread.PSScript.Exec.Status = isRunning) and }(GetTickCount < EndTime) do
Sleep(16);
end else
begin
sleep(t);
end;
end;
{$endif}https://github.com/MerlijnWajer/Simba/blob/1327b37c83a99d14279c25fd610b134bbcadba39/Units/MMLAddon/PSInc/Wrappers/other.inc#L402015-06-17 14:48:41
2015-06-17 18:13:13
From: Olly
It's exactly the same… Wait just calls sleep iirc. If you want to know why its there ask who added Wait to scar.
2015-06-18 04:01:33
From: Turpinator
yup.https://github.com/MerlijnWajer/Simba/blob/1327b37c83a99d14279c25fd610b134bbcadba39/Units/MMLAddon/PSInc/Wrappers/other.inc#L40procedure ps_Wait(t: DWord); extdecl;
{$ifdef MSWINDOWS}
begin
Sleep(t);
end;
{$else}
var
EndTime : DWord;
begin
if t > 50 then
begin;
EndTime := GetTickCount + t;
while {(CurrThread.PSScript.Exec.Status = isRunning) and }(GetTickCount < EndTime) do
Sleep(16);
end else
begin
sleep(t);
end;
end;
{$endif}
So we are clear, lape_Wait() calls ps_Wait() (the proc above).