예제 #1
0
            public override void Run()
            {
                try
                {
                    ReadySignal.Signal();
                    awaitLatch(StartSignal);
                    while (!End.get())
                    {
                        long id;

                        // Ids must be offered in order
                        lock ( Queue )
                        {
                            id = IdSource.next();
                            Queue.offer(id);
                        }

                        Queue.waitFor(id);
                        for (int i = 0, max = Random.Next(10_000); i < max; i++)
                        {
                            // Jit - please don't take this loop away. Look busy... check queue for empty, or something!
                            Queue.Empty;
                        }
                        Queue.removeChecked(id);
                    }
                }
                catch (Exception e)
                {
                    this.Exception = e;
                }
            }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public TransactionApplier startTx(org.neo4j.storageengine.api.CommandsToApply transaction) throws java.io.IOException
        public override TransactionApplier StartTx(CommandsToApply transaction)
        {
            long activeTransactionId = transaction.TransactionId();

            try
            {
                // Cache transactionApplier because it has some expensive lookups
                if (_txApplier == null)
                {
                    _txApplier = new ExplicitIndexTransactionApplier(_applierLookup, _indexConfigStore, _mode, _transactionOrdering);
                }

                if (transaction.RequiresApplicationOrdering())
                {
                    // Index operations must preserve order so wait for previous tx to finish
                    _transactionOrdering.waitFor(activeTransactionId);
                    // And set current tx so we can notify the next transaction when we are finished
                    if (transaction.Next() != null)
                    {
                        // Let each transaction notify the next
                        _txApplier.TransactionId = activeTransactionId;
                    }
                    else
                    {
                        // except the last transaction, which notifies that it is done after appliers have been closed
                        _lastTransactionId = activeTransactionId;
                    }
                }

                return(_txApplier);
            }
            catch (InterruptedException e)
            {
                Thread.CurrentThread.Interrupt();
                throw new IOException("Interrupted while waiting for applying tx:" + activeTransactionId + " explicit index updates", e);
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void waitFor(long value) throws InterruptedException
            public override void WaitFor(long value)
            {
                Delegate.waitFor(value);
            }