コード例 #1
0
 /// <summary>
 /// Closes this strategy and releases any ZooKeeper resources; but keeps the
 ///  ZooKeeper instance open
 /// </summary>
 public void close()
 {
     if (closed.TrySetValue(0, 1))
     {
         doClose();
     }
 }
コード例 #2
0
        internal override async Task doTransport(int waitTimeOut)
        {
            await Task.WhenAny(somethingIsPending.Task, Task.Delay(waitTimeOut < 0 ? 0 : waitTimeOut)).ConfigureAwait(false);

            somethingIsPending.Reset();

            // Everything below and until we get back to the select is
            // non blocking, so time is effectively a constant. That is
            // Why we just have to do this once, here
            updateNow();

            if (Connectable)
            {
                if (connectEventArgs.SocketError == SocketError.Success)
                {
                    updateLastSendAndHeard();
                    clientCnxn.primeConnection();
                }
                else
                {
                    throw new SocketException((int)connectEventArgs.SocketError);
                }
            }

            doIO();

            if (pendingIncomingDataNotifierState.TrySetValue(NOTRUNNING, RUNNING))
            {
                if (socket.ReceiveAsync(receiveEventArgs) == false)
                {
                    ReceiveCompleted();
                }
            }

            if (receiveEventArgs.SocketError != SocketError.Success)
            {
                throw new SocketException((int)receiveEventArgs.SocketError);
            }

            if (clientCnxn.getState().isConnected())
            {
                lock (clientCnxn.outgoingQueue)
                {
                    if (findSendablePacket() != null)
                    {
                        enableWrite();
                    }
                }
            }
        }