semaphore.lock

Syntax semaphore.lock (name, timeout)

Params name is a string specifying which semaphore to lock

timeout is the number of ticks to wait before giving up

Action Attempts to lock the specified semaphore. If the semaphore is locked by another script, waits until the semaphore is released or until timeout ticks expire,

whichever comes first.

Returns true if the semaphore was locked successfully; otherwise generates an error

Examples semaphore.lock ("Mine!", 0)

   » true

semaphore.lock ("Mine!", 20)

   » error: the semaphore is still locked from the above line

semaphore.unlock ("Mine!")

   » true // always unlock when you're done with it

Errors If the semaphore can't be locked before the timeout expires, this verb generates an error.

Notes Semaphores are stored in the system.compiler.semaphores table; the value of each semaphore is a date value containing the time the semaphore was created.

Semaphores are not linked to ODB cells; locking a semaphore called "user.prefs.name" does not have any effect (such as preventing modification) on the ODB object user.prefs.name.

See Also semaphore.unlock

semaphore.unlockAll

Discuss