Example #1
0
 ///<summary>Retrieve the next waiting continuation.</summary>
 ///<remarks>
 ///<para>
 /// It is an error to call this method when there are no
 /// waiting continuations. In the current implementation, if
 /// this happens, null will be returned (which will usually
 /// result in an immediate NullPointerException in the
 /// caller). Correct code will always arrange for a
 /// continuation to have been Enqueue()d before calling this
 /// method.
 ///</para>
 ///</remarks>
 public IRpcContinuation Next()
 {
     lock (m_outstandingRpcLock)
     {
         IRpcContinuation result = m_outstandingRpc;
         m_outstandingRpc = null;
         return(result);
     }
 }
        ///<summary>Enqueue a continuation, marking a pending RPC.</summary>
        ///<remarks>
        ///<para>
        /// Continuations are retrieved in FIFO order by calling Next().
        ///</para>
        ///<para>
        /// In the current implementation, only one continuation can
        /// be queued up at once. Calls to Enqueue() when a
        /// continuation is already enqueued will result in
        /// NotSupportedException being thrown.
        ///</para>
        ///</remarks>
        public void Enqueue(IRpcContinuation k)
        {
            var result = Interlocked.CompareExchange(ref this.m_outstandingRpc, k, tmp);

            if (!(result is EmptyRpcContinuation))
            {
                throw new NotSupportedException("Pipelining of requests forbidden");
            }
        }
Example #3
0
        ///<summary>Interrupt all waiting continuations.</summary>
        ///<remarks>
        ///<para>
        /// There's just the one potential waiter in the current
        /// implementation.
        ///</para>
        ///</remarks>
        public void HandleModelShutdown(ShutdownEventArgs reason)
        {
            IRpcContinuation k = Next();

            if (k != null)
            {
                k.HandleModelShutdown(reason);
            }
        }
Example #4
0
        public void TestRpcContinuationQueueEnqueueAndRelease()
        {
            RpcContinuationQueue queue = new RpcContinuationQueue();
            var inputContinuation      = new SimpleBlockingRpcContinuation();

            queue.Enqueue(inputContinuation);
            IRpcContinuation outputContinuation = queue.Next();

            Assert.AreEqual(outputContinuation, inputContinuation);
        }
Example #5
0
 ///<summary>Enqueue a continuation, marking a pending RPC.</summary>
 ///<remarks>
 ///<para>
 /// Continuations are retrieved in FIFO order by calling Next().
 ///</para>
 ///<para>
 /// In the current implementation, only one continuation can
 /// be queued up at once. Calls to Enqueue() when a
 /// continuation is already enqueued will result in
 /// NotSupportedException being thrown.
 ///</para>
 ///</remarks>
 public void Enqueue(IRpcContinuation k)
 {
     lock (m_outstandingRpcLock)
     {
         if (m_outstandingRpc != null)
         {
             throw new NotSupportedException("Pipelining of requests forbidden");
         }
         m_outstandingRpc = k;
     }
 }
 ///<summary>Enqueue a continuation, marking a pending RPC.</summary>
 ///<remarks>
 ///<para>
 /// Continuations are retrieved in FIFO order by calling Next().
 ///</para>
 ///<para>
 /// In the current implementation, only one continuation can
 /// be queued up at once. Calls to Enqueue() when a
 /// continuation is already enqueued will result in
 /// NotSupportedException being thrown.
 ///</para>
 ///</remarks>
 public void Enqueue(IRpcContinuation k)
 {
     lock (m_outstandingRpcLock)
     {
         if (m_outstandingRpc != null)
         {
             throw new NotSupportedException("Pipelining of requests forbidden");
         }
         m_outstandingRpc = k;
     }
 }
Example #7
0
 public void TransmitAndEnqueue(Command cmd, IRpcContinuation k)
 {
     Enqueue(k);
     try
     {
         m_session.Transmit(cmd);
     }
     catch (AlreadyClosedException)
     {
         // Ignored, since the continuation will be told about
         // the closure via an OperationInterruptedException because
         // of the shutdown event propagation.
     }
 }
Example #8
0
        public void Enqueue(IRpcContinuation k)
        {
            bool ok = false;

            lock (m_shutdownLock)
            {
                if (m_closeReason == null)
                {
                    m_continuationQueue.Enqueue(k);
                    ok = true;
                }
            }
            if (!ok)
            {
                k.HandleModelShutdown(m_closeReason);
            }
        }
 public void TransmitAndEnqueue(Command cmd, IRpcContinuation k)
 {
     Enqueue(k);
     m_session.Transmit(cmd);
 }
 public void Enqueue(IRpcContinuation k)
 {
     bool ok = false;
     lock (m_shutdownLock)
     {
         if (m_closeReason == null)
         {
             m_continuationQueue.Enqueue(k);
             ok = true;
         }
     }
     if (!ok)
     {
         k.HandleModelShutdown(m_closeReason);
     }
 }
 ///<summary>Retrieve the next waiting continuation.</summary>
 ///<remarks>
 ///<para>
 /// It is an error to call this method when there are no
 /// waiting continuations. In the current implementation, if
 /// this happens, null will be returned (which will usually
 /// result in an immediate NullPointerException in the
 /// caller). Correct code will always arrange for a
 /// continuation to have been Enqueue()d before calling this
 /// method.
 ///</para>
 ///</remarks>
 public IRpcContinuation Next()
 {
     lock (m_outstandingRpcLock)
     {
         IRpcContinuation result = m_outstandingRpc;
         m_outstandingRpc = null;
         return result;
     }
 }
 public void TransmitAndEnqueue(Command cmd, IRpcContinuation k)
 {
     Enqueue(k);
     try
     {
         m_session.Transmit(cmd);
     }
     catch (AlreadyClosedException)
     {
         // Ignored, since the continuation will be told about
         // the closure via an OperationInterruptedException because
         // of the shutdown event propagation.
     }
 }
        ///<summary>Interrupt all waiting continuations.</summary>
        ///<remarks>
        ///<para>
        /// There's just the one potential waiter in the current
        /// implementation.
        ///</para>
        ///</remarks>
        public void HandleModelShutdown(ShutdownEventArgs reason)
        {
            IRpcContinuation k = Next();

            k?.HandleModelShutdown(reason);
        }
 ///<summary>Enqueue a continuation, marking a pending RPC.</summary>
 ///<remarks>
 ///<para>
 /// Continuations are retrieved in FIFO order by calling Next().
 ///</para>
 ///<para>
 /// In the current implementation, only one continuation can
 /// be queued up at once. Calls to Enqueue() when a
 /// continuation is already enqueued will result in
 /// NotSupportedException being thrown.
 ///</para>
 ///</remarks>
 public void Enqueue(IRpcContinuation k)
 {
     m_outstandingRpc.Enqueue(k);
 }