Learn R Programming

flock (version 0.7)

lock: Locking/Unlocking

Description

Locks a file in exclusive or shared mode.

Usage

lock(path, exclusive = TRUE)

Arguments

path
Character. The path.
exclusive
Logical. The lock type, exclusive or shared.

Value

Returns an object of type FileLock, which is to be used for the unlock call.

Details

The file is created if it doesn't exist.

Examples

Run this code
## Not run: 
# require(flock)
# 
# file.lock = lock("~/file.lock")
# # Critical section code goes here
# unlock(file.lock)
# ## End(Not run)

Run the code above in your browser using DataLab