//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void terminateSharedLockAcquisition() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TerminateSharedLockAcquisition() { _client.acquireExclusive(LockTracer.NONE, ResourceTypes.Node, 1); Future <bool> sharedLockAcquisition = ThreadB.execute(state => { _client2.acquireShared(LockTracer.NONE, ResourceTypes.Node, 1); return(true); }); assertThat(ThreadB, Waiting); _clock.forward(101, TimeUnit.MILLISECONDS); VerifyAcquisitionFailure(sharedLockAcquisition); }
private void FlushLocks(LockTracer lockTracer, long[] current, int cursor, ResourceType currentType, bool exclusive) { if (cursor > 0) { long[] resourceIds = Arrays.copyOf(current, cursor); if (exclusive) { _clientDelegate.acquireExclusive(lockTracer, currentType, resourceIds); } else { _clientDelegate.acquireShared(lockTracer, currentType, resourceIds); } } }
public override void Run() { try { StartSignal.await(); Stack <object> lockStack = new Stack <object>(); for (int i = 0; i < NumberOfIterations; i++) { try { int depth = DepthCount; do { float f = Rand.nextFloat(); if (f < ReadWriteRatio) { Client.acquireShared(LockTracer.NONE, NODE, NodeId); lockStack.Push(Read); } else { Client.acquireExclusive(LockTracer.NONE, NODE, NodeId); lockStack.Push(Write); } } while (--depth > 0); while (lockStack.Count > 0) { if (lockStack.Pop() == Read) { Client.releaseShared(NODE, NodeId); } else { Client.releaseExclusive(NODE, NodeId); } } } catch (DeadlockDetectedException) { } finally { while (lockStack.Count > 0) { if (lockStack.Pop() == Read) { Client.releaseShared(NODE, NodeId); } else { Client.releaseExclusive(NODE, NodeId); } } } } } catch (Exception e) { Error = e; } }