GunnerMBT / csharptest-net

Automatically exported from code.google.com/p/csharptest-net
0 stars 0 forks source link

BPlusTree: Meaningless AssertionFailedException if the lock was not acquired #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If the CallLevel lock cannot be acquired due to timeout then the Assertion is 
triggered. In this case it would be better to throw some specific exception 
derived from TimeoutException, so the user code can react appropriately. 

There are a couple of lines in the constructor of RootLock:
   _locked = _exclusive ? _tree._selfLock.TryWrite(tree._options.LockTimeout) : _tree._selfLock.TryRead(tree._options.LockTimeout);
   Assert(_locked);

Instead I suggest to do this:
   _locked = _exclusive ? _tree._selfLock.TryWrite(tree._options.LockTimeout) : _tree._selfLock.TryRead(tree._options.LockTimeout);
   if (!_locked)
      throw new BPlusTreeTimeoutException("...");

Original issue reported on code.google.com by Frame...@gmail.com on 28 May 2014 at 12:51

GoogleCodeExporter commented 8 years ago
Issue moved:
https://github.com/csharptest/CSharpTest.Net.Collections/issues/6

Original comment by Grig...@gmail.com on 29 Jan 2015 at 5:45