diff options
-rw-r--r-- | global-functions | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/global-functions b/global-functions index 6c11258..a19e44b 100644 --- a/global-functions +++ b/global-functions @@ -906,6 +906,7 @@ :set ScriptLock do={ :local Script [ :tostr $1 ]; :local DoReturn $2; + :local DoWait $3; :global GetRandomNumber; :global IfThenElse; @@ -949,6 +950,11 @@ :local MyTicket [ $GetRandomNumber ]; :set ($ScriptLockOrder->$Script) [ $AddTicket ($ScriptLockOrder->$Script) $MyTicket ]; + :while ($DoWait = true && (($ScriptLockOrder->$Script->0) != $MyTicket || [ :len ($ScriptLockOrder->$Script) ] < $JobCount)) do={ + :delay 100ms; + :set JobCount [ :len [ / system script job find where script=$Script ] ]; + } + :if ([ :len ($ScriptLockOrder->$Script) ] = $JobCount && ($ScriptLockOrder->$Script->0) = $MyTicket) do={ :set ($ScriptLockOrder->$Script) [ $RemoveTicket ($ScriptLockOrder->$Script) $MyTicket ]; :return false; |