Commit e0c64161 authored by Jim Fulton's avatar Jim Fulton

No-longer need loks, since we're only accessed from the asyncio thread.

parent a2a34a88
...@@ -29,7 +29,6 @@ import BTrees.LOBTree ...@@ -29,7 +29,6 @@ import BTrees.LOBTree
import logging import logging
import os import os
import tempfile import tempfile
import threading
import time import time
import ZODB.fsIndex import ZODB.fsIndex
...@@ -131,16 +130,6 @@ allocated_record_overhead = 43 ...@@ -131,16 +130,6 @@ allocated_record_overhead = 43
# to the end of the file that the new object can't fit in one # to the end of the file that the new object can't fit in one
# contiguous chunk, currentofs is reset to ZEC_HEADER_SIZE first. # contiguous chunk, currentofs is reset to ZEC_HEADER_SIZE first.
def locked(func):
def _locked_wrapper(inst, *args, **kwargs):
inst._lock.acquire()
try:
return func(inst, *args, **kwargs)
finally:
inst._lock.release()
return _locked_wrapper
# Under PyPy, the available dict specializations perform significantly # Under PyPy, the available dict specializations perform significantly
# better (faster) than the pure-Python BTree implementation. They may # better (faster) than the pure-Python BTree implementation. They may
# use less memory too. And we don't require any of the special BTree features... # use less memory too. And we don't require any of the special BTree features...
...@@ -243,8 +232,6 @@ class ClientCache(object): ...@@ -243,8 +232,6 @@ class ClientCache(object):
self._setup_trace(path) self._setup_trace(path)
self._lock = threading.RLock()
# Backward compatibility. Client code used to have to use the fc # Backward compatibility. Client code used to have to use the fc
# attr to get to the file cache to get cache stats. # attr to get to the file cache to get cache stats.
@property @property
...@@ -463,7 +450,6 @@ class ClientCache(object): ...@@ -463,7 +450,6 @@ class ClientCache(object):
# instance, and also written out near the start of the cache file. The # instance, and also written out near the start of the cache file. The
# new tid must be strictly greater than our current idea of the most # new tid must be strictly greater than our current idea of the most
# recent tid. # recent tid.
@locked
def setLastTid(self, tid): def setLastTid(self, tid):
if (not tid) or (tid == z64): if (not tid) or (tid == z64):
return return
...@@ -492,8 +478,6 @@ class ClientCache(object): ...@@ -492,8 +478,6 @@ class ClientCache(object):
# @return (data record, serial number, tid), or None if the object is not # @return (data record, serial number, tid), or None if the object is not
# in the cache # in the cache
# @defreturn 3-tuple: (string, string, string) # @defreturn 3-tuple: (string, string, string)
@locked
def load(self, oid): def load(self, oid):
ofs = self.current.get(oid) ofs = self.current.get(oid)
if ofs is None: if ofs is None:
...@@ -545,8 +529,6 @@ class ClientCache(object): ...@@ -545,8 +529,6 @@ class ClientCache(object):
# @param tid id of transaction that wrote next revision of oid # @param tid id of transaction that wrote next revision of oid
# @return data record, serial number, start tid, and end tid # @return data record, serial number, start tid, and end tid
# @defreturn 4-tuple: (string, string, string, string) # @defreturn 4-tuple: (string, string, string, string)
@locked
def loadBefore(self, oid, before_tid): def loadBefore(self, oid, before_tid):
noncurrent_for_oid = self.noncurrent.get(u64(oid)) noncurrent_for_oid = self.noncurrent.get(u64(oid))
if noncurrent_for_oid is None: if noncurrent_for_oid is None:
...@@ -592,8 +574,6 @@ class ClientCache(object): ...@@ -592,8 +574,6 @@ class ClientCache(object):
# revision of oid. If end_tid is None, the data is # revision of oid. If end_tid is None, the data is
# current. # current.
# @param data the actual data # @param data the actual data
@locked
def store(self, oid, start_tid, end_tid, data): def store(self, oid, start_tid, end_tid, data):
seek = self.f.seek seek = self.f.seek
if end_tid is None: if end_tid is None:
...@@ -699,7 +679,6 @@ class ClientCache(object): ...@@ -699,7 +679,6 @@ class ClientCache(object):
# - oid object id # - oid object id
# - tid the id of the transaction that wrote a new revision of oid, # - tid the id of the transaction that wrote a new revision of oid,
# or None to forget all cached info about oid. # or None to forget all cached info about oid.
@locked
def invalidate(self, oid, tid): def invalidate(self, oid, tid):
ofs = self.current.get(oid) ofs = self.current.get(oid)
if ofs is None: if ofs is None:
...@@ -740,19 +719,13 @@ class ClientCache(object): ...@@ -740,19 +719,13 @@ class ClientCache(object):
seek = self.f.seek seek = self.f.seek
read = self.f.read read = self.f.read
for oid, ofs in six.iteritems(self.current): for oid, ofs in six.iteritems(self.current):
self._lock.acquire() seek(ofs)
try: status = read(1)
seek(ofs) assert status == b'a', (ofs, self.f.tell(), oid)
status = read(1) size, saved_oid, tid, end_tid = unpack(">I8s8s8s", read(28))
assert status == b'a', (ofs, self.f.tell(), oid) assert saved_oid == oid, (ofs, self.f.tell(), oid, saved_oid)
size, saved_oid, tid, end_tid = unpack(">I8s8s8s", read(28)) assert end_tid == z64, (ofs, self.f.tell(), oid)
assert saved_oid == oid, (ofs, self.f.tell(), oid, saved_oid) yield oid, tid
assert end_tid == z64, (ofs, self.f.tell(), oid)
result = oid, tid
finally:
self._lock.release()
yield result
def dump(self): def dump(self):
from ZODB.utils import oid_repr from ZODB.utils import oid_repr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment