[CalendarServer-changes] [10240] CalendarServer/branches/users/glyph/queue-locking-and-timing

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 4 16:38:56 PST 2013


Revision: 10240
          http://trac.calendarserver.org//changeset/10240
Author:   glyph at apple.com
Date:     2013-01-04 16:38:56 -0800 (Fri, 04 Jan 2013)
Log Message:
-----------
Specification for locker and lock classes.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/queue-locking-and-timing/

Modified: CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py
===================================================================
--- CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py	2013-01-05 00:38:55 UTC (rev 10239)
+++ CalendarServer/branches/users/glyph/queue-locking-and-timing/twext/enterprise/queue.py	2013-01-05 00:38:56 UTC (rev 10240)
@@ -378,7 +378,63 @@
         ))
 
 
+class AlreadyUnlocked(Exception):
+    """
+    The lock you were trying to unlock was already unlocked.
+    """
 
+
+
+class AcquiredLock(object):
+    """
+    An L{AcquiredLock} lock against a shared data store that the current
+    process holds via the referenced transaction.
+    """
+
+    def release(self, ignoreAlreadyUnlocked=False):
+        """
+        Release this lock.
+
+        @param ignoreAlreadyUnlocked: If you don't care about the current
+            status of this lock, and just want to release it if it is still
+            acquired, pass this parameter as L{True}.  Otherwise this method
+            will raise an exception if it is invoked when the lock has already
+            been released.
+
+        @raise: L{AlreadyUnlocked}
+
+        @return: A L{Deferred} that fires with L{None} when the lock has been
+            unlocked.
+        """
+        raise NotImplementedError()
+
+
+
+
+class Locker(object):
+    """
+    Acquire named locks against a database.
+    """
+
+    def lock(self, name, wait=False):
+        """
+        Acquire a lock with the given name.
+
+        @param name: The name of the lock to acquire.  Against the same store,
+            no two locks may be acquired.
+        @type name: L{unicode}
+
+        @param wait: Whether or not to wait for the lock.  If L{True}, the
+            L{Deferred} returned by L{lock} make some time to fire; if
+            L{False}, it should quickly fail instead.
+
+        @return: a L{Deferred} that fires with an L{AcquiredLock} when the lock
+            has fired, or fails when the lock has not been acquired.
+        """
+        raise NotImplementedError()
+
+
+
 class PerformWork(Command):
     """
     Notify another process that it must do some work that has been persisted to
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130104/7b9a8a28/attachment-0001.html>


More information about the calendarserver-changes mailing list