lock | R Documentation |
A wrapper for 'synchronicity' package, but user can interrupt the lock procedure anytime, and don't have to worry about whether the lock exists or not.
dipsaus_lock(name, timeout = 10, exclusive = TRUE)
dipsaus_unlock(name, timeout = 10, exclusive = TRUE)
dipsaus_resetlocks(name)
name |
character, the locker's name, must be only letters and digits |
timeout |
numeric, seconds to wait for the locker to lock or unlock |
exclusive |
ignored |
Logical, whether the operation succeed.
# Clear existing locks
dipsaus::dipsaus_resetlocks()
# unlock to prepare for the example
dipsaus_unlock('testlocker', timeout = 0.01)
# Create a locker, return TRUE
lock_success = dipsaus_lock('testlocker')
if(lock_success){
cat2('testlocker has been locked')
}
# test whether locker has been locked
lock_success = dipsaus_lock('testlocker', timeout = 0.01)
if(!lock_success){
cat2('attempt to lock testlocker failed')
}
# unlock
dipsaus_unlock('testlocker', timeout = 0.01)
# clean up
dipsaus::dipsaus_resetlocks()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.