'Acquire the lock, returning a context manager.
:param creator: Creation function, used if this thread
is chosen to create a new value.
:param value_fn: Optional function that returns
the value from some datasource.  Will be returned
if regeneration is not needed.
:param value_and_created_fn: Like value_fn, but returns a tuple
of (value, createdtime).  The returned createdtime
will replace the "createdtime" value on this dogpile
lock.   This option removes the need for the dogpile lock
itself to remain persistent across usages; another
dogpile can come along later and pick up where the
previous one left off.'

def acquire(self, creator, value_fn=None, value_and_created_fn=None):

    if (value_and_created_fn is None):
        if (value_fn is None):
            def value_and_created_fn():
                return (None, self.createdtime)
        else:
            def value_and_created_fn():
                return (value_fn(), self.createdtime)
        def creator_wrapper():
            value = creator()
            self.createdtime = time.time()
            return (value, self.createdtime)
    else:
        def creator_wrapper():
            value = creator()
            self.createdtime = time.time()
            return value
    return Lock(self.dogpilelock, creator_wrapper, value_and_created_fn, self.expiretime)
