Пример #1
0
        public IdleWatcher(Loop loop, Action<IdleWatcher, EventTypes> callback)
            : base(loop)
        {
            this.callback = callback;

            watcher_ptr = manos_idle_watcher_create(unmanaged_callback, GCHandle.ToIntPtr(gc_handle));
        }
Пример #2
0
 public TimerWatcher(TimeSpan after, TimeSpan repeat, Loop loop, Action<TimerWatcher, EventTypes> callback)
     : base(loop)
 {
     this.callback = callback;
     this.repeat = repeat;
     watcher_ptr = manos_timer_watcher_create (after.TotalSeconds, repeat.TotalSeconds, unmanaged_callback, GCHandle.ToIntPtr (gc_handle));
 }
Пример #3
0
 public IOWatcher(IntPtr fd, EventTypes types, Loop loop, Action<IOWatcher, EventTypes> callback)
     : base(loop)
 {
     this.fd = fd;
     this.callback = callback;
     watcher_ptr = manos_io_watcher_create (fd.ToInt32 (), types, watcherCallback, GCHandle.ToIntPtr (gc_handle));
 }
Пример #4
0
 public EioContext(Loop parent)
 {
     eioHandlerCb = EioHandler;
     outstanding = new ConcurrentQueue<Action> ();
     pulse = new AsyncWatcher (parent, eioHandlerCb);
     pulse.Start ();
 }
Пример #5
0
        public IOLoop()
        {
            evloop = Loop.CreateDefaultLoop (0);

            prepare_watcher = new PrepareWatcher (evloop, HandlePrepareEvent);
            prepare_watcher.Start ();
        }
Пример #6
0
        internal Watcher(Loop loop)
        {
            Loop = loop;

            unmanaged_callback = new UnmanagedWatcherCallback (UnmanagedCallbackHandler);
            unmanaged_callback_ptr = Marshal.GetFunctionPointerForDelegate (unmanaged_callback);
        }
Пример #7
0
        static EioContext()
        {
            eioLoop = new Loop ();
            manos_init (eioLoop.Handle);

            eioHandlerThread = new Thread (EioHandler);
            eioHandlerThread.IsBackground = true;
            eioHandlerThread.Start ();
        }
Пример #8
0
        public IOLoop()
        {
            evloop = Loop.CreateDefaultLoop (0);
            eio = new Libeio.Libeio ();

            //			eio.Initialize (evloop);

            libmanos_data = manos_init (evloop.Handle);
        }
Пример #9
0
        public IOLoop()
        {
            evloop = Loop.CreateDefaultLoop (0);
            eio = new Libeio.Libeio ();

            eio.Initialize (evloop);

            prepare_watcher = new PrepareWatcher (evloop, HandlePrepareEvent);
            prepare_watcher.Start ();
        }
Пример #10
0
        public CheckWatcher(Loop loop, CheckWatcherCallback callback)
            : base(loop)
        {
            this.callback = callback;

            unmanaged_watcher = new UnmanagedCheckWatcher ();
            unmanaged_watcher.callback = CallbackFunctionPtr;

            InitializeUnmanagedWatcher (unmanaged_watcher);
        }
Пример #11
0
        public PrepareWatcher(Loop loop, PrepareWatcherCallback callback)
            : base(loop)
        {
            this.callback = callback;

            unmanaged_watcher = new UnmanagedPrepareWatcher ();
            unmanaged_watcher.callback = unmanaged_callback_ptr;

            InitializeUnmanagedWatcher (unmanaged_watcher);
        }
Пример #12
0
        public TimerWatcher(TimeSpan after, TimeSpan repeat, Loop loop, TimerWatcherCallback callback)
            : base(loop)
        {
            this.callback = callback;

            unmanaged_watcher = new UnmanagedTimerWatcher ();

            unmanaged_watcher.callback = CallbackFunctionPtr;
            unmanaged_watcher.after = after.TotalSeconds;
            unmanaged_watcher.repeat = after.TotalSeconds;

            InitializeUnmanagedWatcher (unmanaged_watcher);
        }
Пример #13
0
        public IOWatcher(IntPtr fd, EventTypes types, Loop loop, IOWatcherCallback callback)
            : base(loop)
        {
            this.fd = fd;
            this.callback = callback;

            unmanaged_watcher = new UnmanagedIOWatcher ();

            unmanaged_watcher.fd = fd.ToInt32 ();
            unmanaged_watcher.events = types | EventTypes.EV__IOFDSET;

            unmanaged_watcher.callback = CallbackFunctionPtr;

            InitializeUnmanagedWatcher (unmanaged_watcher);
        }
Пример #14
0
        public void Initialize(Loop loop)
        {
            /*
            idle_watcher = new IdleWatcher (loop, OnIdle);
            want_poll_watcher = new AsyncWatcher (loop, OnWantPoll);
            done_poll_watcher = new AsyncWatcher (loop, OnDonePoll);

            idle_watcher.Start ();
            want_poll_watcher.Start ();
            done_poll_watcher.Start ();
            */
        }
Пример #15
0
        private void HandleIOEvents(Loop loop, IOWatcher watcher, EventTypes revents)
        {
            while (true) {
                  	Socket s = null;
                try {
                    s = Socket.Accept ();
                } catch (SocketException se) {
                    if (se.SocketErrorCode == SocketError.WouldBlock || se.SocketErrorCode == SocketError.TryAgain)
                        return;
                    throw se;
                } catch {
                    throw;
                }

                IOStream iostream = new IOStream (s, IOLoop);
                transactions.Add (HttpTransaction.BeginTransaction (this, iostream, s, callback));
            }
        }
Пример #16
0
        private void OnIdle(Loop loop, IdleWatcher watcher, EventTypes revents)
        {
            Console.WriteLine ("ON IDLE");

            if (eio_poll () != -1) {
                Console.WriteLine ("OnIdle: Stopping idle watcher");
                idle_watcher.Stop ();
            }
        }
Пример #17
0
        private void HandleIOEvents(Loop loop, IOWatcher watcher, EventTypes revents)
        {
            while (true) {
                  	Socket s = null;
                try {
                    s = Socket.Accept ();
                } catch (SocketException se) {
                    if (se.SocketErrorCode == SocketError.WouldBlock || se.SocketErrorCode == SocketError.TryAgain)
                        return;
                    Console.WriteLine ("Socket exception in Accept handler");
                    Console.WriteLine (se);
                    return;
                } catch (Exception e) {
                    Console.WriteLine ("Exception in Accept handler");
                    Console.WriteLine (e);
                    return;
                }

                IOStream iostream = new IOStream (s, IOLoop);
                transactions.Add (HttpTransaction.BeginTransaction (this, iostream, s, callback));
            }
        }
Пример #18
0
        private void HandleTimeout(Loop loop, TimerWatcher timeout, EventTypes revents)
        {
            Timeout t = (Timeout) timeout.UserData;

            AppHost.RunTimeout (t);
            if (!t.ShouldContinueToRepeat ())
               timeout.Stop ();
        }
Пример #19
0
        private void HandleIOWrite(Loop loop, IOWatcher watcher, int revents)
        {
            // write ready can still be raised after we are done writing.
            if (send_file == null && write_data == null)
               return;

            if (send_file != null) {
               HandleSendFile ();
               return;
            }

                        HandleWrite ();
        }
Пример #20
0
 private void HandleIORead(Loop loop, IOWatcher watcher, int revents)
 {
     HandleRead ();
 }
Пример #21
0
 private void HandleIOWrite(Loop loop, IOWatcher watcher, int revents)
 {
     HandleWrite ();
 }
Пример #22
0
 private void HandleTimeoutEvent(Loop loop, TimerWatcher watcher, EventTypes revents)
 {
     if (Expires <= DateTime.UtcNow) {
         if (TimedOut != null)
             TimedOut (this, EventArgs.Empty);
         Close ();
     }
 }
Пример #23
0
 public TimerWatcher(TimeSpan repeat, Loop loop, TimerWatcherCallback callback)
     : this(TimeSpan.Zero, repeat, loop, callback)
 {
 }
Пример #24
0
        private void HandleIOWriteEvent(Loop loop, IOWatcher watcher, EventTypes revents)
        {
            // Happens after a close
            if (handle == IntPtr.Zero)
                return;

            Expires = DateTime.UtcNow + TimeOut;
            HandleWrite ();
        }
Пример #25
0
 private void OnWantPoll(Loop loop, AsyncWatcher watcher, EventTypes revents)
 {
     if (eio_poll () == -1) {
         Console.WriteLine ("OnWantPoll: starting idle watcher");
         idle_watcher.Start ();
     }
 }
Пример #26
0
 internal Watcher(Loop loop)
 {
     Loop = loop;
     gc_handle = GCHandle.Alloc (this);
 }
Пример #27
0
 public Context()
 {
     Loop = new Loop ();
     Eio = new EioContext (Loop);
 }
Пример #28
0
 private void HandleIORead(Loop loop, IOWatcher watcher, int revents)
 {
     try {
         HandleRead ();
     } catch (Exception e) {
         Close ();
     }
 }
Пример #29
0
 public IOLoop()
 {
     Synchronize = true;
     loop = new ManagedLoop(this);
 }
Пример #30
0
 private void HandlePrepareEvent(Loop loop, PrepareWatcher watcher, EventTypes revents)
 {
     if (!running) {
        loop.Unloop (UnloopType.All);
        prepare_watcher.Stop ();
         }
 }