public void BeginReceive(bool IOCPThread)
        {
            _lock.AcquireReaderLock();
            try
            {
                if (IsClosed || IsClosing || IsDisconnecting)
                {
                    return; // Already shutting down.
                }
            }
            finally
            {
                _lock.ReleaseReaderLock();
            }
            log4net.ThreadContext.Properties["ClientIP"] = this.RemoteEndPoint;
            if (log.IsDebugEnabled)
            {
                log.Debug(__Res.GetString(__Res.Rtmp_SocketBeginReceive, _connectionId, IOCPThread));
            }

            if (!IOCPThread)
            {
                //ThreadPool.QueueUserWorkItem(new WaitCallback(BeginReceiveCallbackProcessing), null);
                ThreadPoolEx.Global.QueueUserWorkItem(new WaitCallback(BeginReceiveCallbackProcessing), null);
            }
            else
            {
                BeginReceiveCallbackProcessing(null);
            }
        }
Пример #2
0
 public override void Write(RtmpPacket packet)
 {
     _lock.AcquireReaderLock();
     try {
         if (IsClosed || IsClosing)
         {
             return;
         }
     } finally {
         _lock.ReleaseReaderLock();
     }
     try {
         _lock.AcquireWriterLock();
         ByteBuffer data;
         try {
             data = RtmpProtocolEncoder.Encode(this.Context, packet);
         } catch (Exception ex) {
             log.Error("Could not encode message " + packet, ex);
             return;
         }
         // Mark packet as being written
         WritingMessage(packet);
         if (_pendingMessages == null)
         {
             _pendingMessages = new LinkedList();
         }
         _pendingMessages.Add(new PendingData(data, packet));
     } finally {
         _lock.ReleaseWriterLock();
     }
 }
 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 {
     _lock.AcquireReaderLock();
     try {
         if (this.IsClosed)
         {
             throw new ObjectDisposedException(null);
         }
     } finally {
         _lock.ReleaseReaderLock();
     }
     return(_innerStream.BeginRead(buffer, offset, count, callback, state));
 }
Пример #4
0
        // ...

        internal byte[] GetTileFromMemoryCache(RawTile tile)
        {
            kiberCacheLock.AcquireReaderLock();
            try {
                byte[] ret = null;
                if (TilesInMemory.TryGetValue(tile, out ret))
                {
                    return(ret);
                }
            }
            finally {
                kiberCacheLock.ReleaseReaderLock();
            }
            return(null);
        }