parcel | Lucy |
class variable | LUCY_LOCK |
struct symbol | lucy_Lock |
class nickname | lucy_Lock |
header file | Lucy/Store/Lock.h |
Lucy::Store::Lock – Abstract class representing an interprocess mutex lock.
The Lock class produces an interprocess mutex lock. The default subclass uses dot-lock files, but alternative implementations are possible.
Each lock must have a name which is unique per resource to be locked. Each lock also has a “host” id which should be unique per machine; it is used to help clear away stale locks.
lucy_Lock*
lucy_Lock_init(
lucy_Lock *self,
lucy_Folder *folder,
cfish_String *name,
cfish_String *host,
int32_t timeout,
int32_t interval
);
Abstract initializer.
A Folder.
String identifying the resource to be locked, which must consist solely of characters matching [-_.A-Za-z0-9].
A unique per-machine identifier.
Time in milliseconds to keep retrying before abandoning the attempt to Obtain() a lock.
Time in milliseconds between retries.
bool
lucy_Lock_Shared(
lucy_Lock *self
);
Returns true if the Lock is shared, false if the Lock is exclusive.
bool
lucy_Lock_Obtain(
lucy_Lock *self
);
Call Request() once per interval
until Request() returns
success or the timeout
has been reached.
Returns: true on success, false on failure (sets the global error object returned by get_error()).
bool
lucy_Lock_Request(
lucy_Lock *self
);
Make one attempt to acquire the lock.
The semantics of Request() differ depending on whether Shared() returns
true. If the Lock is Shared(), then Request() should not fail if
another lock is held against the resource identified by
name
(though it might fail for other reasons). If it is
not Shared() – i.e. it’s an exclusive (write) lock – then other locks
should cause Request() to fail.
Returns: true on success, false on failure (sets the global error object returned by get_error()).
void
lucy_Lock_Release(
lucy_Lock *self
);
Release the lock.
bool
lucy_Lock_Is_Locked(
lucy_Lock *self
);
Indicate whether the resource identified by this lock’s name is currently locked.
Returns: true if the resource is locked, false otherwise.
void
lucy_Lock_Clear_Stale(
lucy_Lock *self
);
Release all locks that meet the following three conditions: the lock name matches, the host id matches, and the process id that the lock was created under no longer identifies an active process.
Lucy::Store::Lock is a Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.