MoonGen
 All Files Functions Variables Pages
lock.lua File Reference

Lock ... More...

Go to the source code of this file.

Functions

function lock tryLock (timeout)
 Try to acquire the lock, blocking for max <timeout> microseconds. More...
 
function lock __call (func,...)
 Wrap a function call in lock/unlock calls. More...
 

Detailed Description

Lock ...

Todo:
TODO docu

Definition in file lock.lua.

Function Documentation

function lock __call ( func  ,
  ... 
)

Wrap a function call in lock/unlock calls.

Calling this is equivalent to the following pseudo-code:

lock:lock()
try {
func(...)
} finally {
lock:unlock()
}
Parameters
functhe function to call
...arguments passed to the function
function lock tryLock ( timeout  )

Try to acquire the lock, blocking for max <timeout> microseconds.

This function does not block if timeout is <= 0. This function may fail spuriously, i.e. return early or fail to acquire the lock.

Parameters
timeoutmax time to wait in us
Returns
true if the lock was acquired, false otherwise