Пример #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private LockAcquisition acquireTwoLocksInAnotherThread(final boolean firstShared, final boolean secondShared, final java.util.concurrent.CountDownLatch firstLockFailed, final java.util.concurrent.CountDownLatch startSecondLock)
        private LockAcquisition AcquireTwoLocksInAnotherThread(bool firstShared, bool secondShared, System.Threading.CountdownEvent firstLockFailed, System.Threading.CountdownEvent startSecondLock)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LockAcquisition lockAcquisition = new LockAcquisition();
            LockAcquisition lockAcquisition = new LockAcquisition();

            Future <Void> future = ThreadA.execute(state =>
            {
                using (Locks_Client client = NewLockClient(lockAcquisition))
                {
                    try
                    {
                        if (firstShared)
                        {
                            client.AcquireShared(_tracer, NODE, FIRST_NODE_ID);
                        }
                        else
                        {
                            client.AcquireExclusive(_tracer, NODE, FIRST_NODE_ID);
                        }
                        fail("Transaction termination expected");
                    }
                    catch (Exception e)
                    {
                        assertThat(e, instanceOf(typeof(LockClientStoppedException)));
                    }
                }

                lockAcquisition.Client = null;
                firstLockFailed.Signal();
                Await(startSecondLock);

                using (Locks_Client client = NewLockClient(lockAcquisition))
                {
                    if (secondShared)
                    {
                        client.AcquireShared(_tracer, NODE, FIRST_NODE_ID);
                    }
                    else
                    {
                        client.AcquireExclusive(_tracer, NODE, FIRST_NODE_ID);
                    }
                }
                return(null);
            });

            lockAcquisition.SetFuture(future, ThreadA.get());

            return(lockAcquisition);
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private LockAcquisition tryAcquireTwoLocksLockInAnotherThread(final boolean shared, final java.util.concurrent.CountDownLatch firstLockAcquired)
        private LockAcquisition TryAcquireTwoLocksLockInAnotherThread(bool shared, System.Threading.CountdownEvent firstLockAcquired)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LockAcquisition lockAcquisition = new LockAcquisition();
            LockAcquisition lockAcquisition = new LockAcquisition();

            Future <Void> future = ThreadA.execute(state =>
            {
                using (Locks_Client client = NewLockClient(lockAcquisition))
                {
                    if (shared)
                    {
                        client.AcquireShared(_tracer, NODE, SECOND_NODE_ID);
                    }
                    else
                    {
                        client.AcquireExclusive(_tracer, NODE, SECOND_NODE_ID);
                    }

                    firstLockAcquired.Signal();

                    if (shared)
                    {
                        client.AcquireShared(_tracer, NODE, FIRST_NODE_ID);
                    }
                    else
                    {
                        client.AcquireExclusive(_tracer, NODE, FIRST_NODE_ID);
                    }
                }
                return(null);
            });

            lockAcquisition.SetFuture(future, ThreadA.get());

            return(lockAcquisition);
        }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private LockAcquisition acquireSharedAndExclusiveLocksInAnotherThread(final java.util.concurrent.CountDownLatch sharedLockAcquired, final java.util.concurrent.CountDownLatch startExclusiveLock)
        private LockAcquisition AcquireSharedAndExclusiveLocksInAnotherThread(System.Threading.CountdownEvent sharedLockAcquired, System.Threading.CountdownEvent startExclusiveLock)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LockAcquisition lockAcquisition = new LockAcquisition();
            LockAcquisition lockAcquisition = new LockAcquisition();

            Future <Void> future = ThreadA.execute(state =>
            {
                using (Locks_Client client = NewLockClient(lockAcquisition))
                {
                    client.AcquireShared(_tracer, NODE, FIRST_NODE_ID);

                    sharedLockAcquired.Signal();
                    Await(startExclusiveLock);

                    client.AcquireExclusive(_tracer, NODE, FIRST_NODE_ID);
                }
                return(null);
            });

            lockAcquisition.SetFuture(future, ThreadA.get());

            return(lockAcquisition);
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private LockAcquisition acquireLockInAnotherThread(final boolean shared)
        private LockAcquisition AcquireLockInAnotherThread(bool shared)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LockAcquisition lockAcquisition = new LockAcquisition();
            LockAcquisition lockAcquisition = new LockAcquisition();

            Future <Void> future = ThreadA.execute(state =>
            {
                Locks_Client client = NewLockClient(lockAcquisition);
                if (shared)
                {
                    client.AcquireShared(_tracer, NODE, FIRST_NODE_ID);
                }
                else
                {
                    client.AcquireExclusive(_tracer, NODE, FIRST_NODE_ID);
                }
                return(null);
            });

            lockAcquisition.SetFuture(future, ThreadA.get());

            return(lockAcquisition);
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void doWork(Locks_Client client) throws org.neo4j.storageengine.api.lock.AcquireLockTimeoutException
                public override void doWork(Locks_Client client)
                {
                    client.AcquireShared(_tracer, _resourceType, _key);
                }