Exemplo n.º 1
0
        public void ReadAsync(byte[] buffer, int offset, int count, Action <int> endAction)
        {
            if (_stream.DataAvailable)
            {
                Logger.Trace("Reading data synchronously");
                var read = _stream.Read(buffer, offset, count);
                if (Logger.IsTraceEnabled)
                {
                    Logger.TraceFormat("Read data synchronously {0}", read);
                }

                _daemon.Schedule(
                    () => endAction(read));
            }
            Logger.Trace("Reading data asynchronously");
            try
            {
                _stream.BeginRead(buffer, offset, count,
                                  asyncResult => _daemon.Schedule(
                                      () => HandleEndRead(endAction, asyncResult)), null);
            }
            catch (IOException exception)
            {
                Logger.Debug("Connection Reset by Peer", exception);
                _daemon.Shutdown();
            }
        }
Exemplo n.º 2
0
 private static void Increment(IDaemon daemon, int i)
 {
     _countArray[i]++;
     if (_countArray[i] != _messagesPerProcess)
     {
         daemon.Schedule(() => Increment(daemon, i));
         return;
     }
     if(Interlocked.Decrement(ref _countDown) == 0)
         Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start));
 }
Exemplo n.º 3
0
 private static void Increment(IDaemon daemon, int i)
 {
     _countArray[i]++;
     if (_countArray[i] != _messagesPerProcess)
     {
         daemon.Schedule(() => Increment(daemon, i));
         return;
     }
     if (Interlocked.Decrement(ref _countDown) == 0)
     {
         Console.WriteLine("Time: {0}", (DateTime.UtcNow - _start));
     }
 }
Exemplo n.º 4
0
 public void Initialize(IReactor reactor, IDaemon daemon)
 {
     reactor.Daemon = daemon;
     daemon.Schedule(reactor.Initialize);
 }
Exemplo n.º 5
0
 public void Initialize(IReactor reactor, IDaemon daemon)
 {
     reactor.Daemon = daemon;
     daemon.Schedule(reactor.Initialize);
 }