Class: Ferret::Store::Lock

Inherits:
Object
  • Object
show all
Defined in:
ext/r_store.c

Overview

A Lock is used to lock a data source so that not more than one output stream can access a data source at one time. It is possible that locks could be disabled. For example a read only index stored on a CDROM would have no need for a lock.

You can use a lock in two ways. Firstly:

write_lock = @directory.make_lock(LOCK_NAME)
write_lock.obtain(WRITE_LOCK_TIME_OUT)
  ... # Do your file modifications # ...
write_lock.release()

Alternatively you could use the while locked method. This ensures that the lock will be released once processing has finished.

write_lock = @directory.make_lock(LOCK_NAME)
write_lock.while_locked(WRITE_LOCK_TIME_OUT) do
  ... # Do your file modifications # ...
end