Example #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));
        }
Example #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));
 }
Example #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));
 }
Example #4
0
 public EioContext(Loop parent)
 {
     eioHandlerCb = EioHandler;
     outstanding = new ConcurrentQueue<Action> ();
     pulse = new AsyncWatcher (parent, eioHandlerCb);
     pulse.Start ();
 }
Example #5
0
        public IOLoop()
        {
            evloop = Loop.CreateDefaultLoop (0);

            prepare_watcher = new PrepareWatcher (evloop, HandlePrepareEvent);
            prepare_watcher.Start ();
        }
Example #6
0
        internal Watcher(Loop loop)
        {
            Loop = loop;

            unmanaged_callback = new UnmanagedWatcherCallback (UnmanagedCallbackHandler);
            unmanaged_callback_ptr = Marshal.GetFunctionPointerForDelegate (unmanaged_callback);
        }
Example #7
0
        static EioContext()
        {
            eioLoop = new Loop ();
            manos_init (eioLoop.Handle);

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

            //			eio.Initialize (evloop);

            libmanos_data = manos_init (evloop.Handle);
        }
Example #9
0
        public IOLoop()
        {
            evloop = Loop.CreateDefaultLoop (0);
            eio = new Libeio.Libeio ();

            eio.Initialize (evloop);

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

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

            InitializeUnmanagedWatcher (unmanaged_watcher);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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 ();
            */
        }
Example #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));
            }
        }
Example #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 ();
            }
        }
Example #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));
            }
        }
Example #18
0
        private void HandleTimeout(Loop loop, TimerWatcher timeout, EventTypes revents)
        {
            Timeout t = (Timeout) timeout.UserData;

            AppHost.RunTimeout (t);
            if (!t.ShouldContinueToRepeat ())
               timeout.Stop ();
        }
Example #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 ();
        }
Example #20
0
 private void HandleIORead(Loop loop, IOWatcher watcher, int revents)
 {
     HandleRead ();
 }
Example #21
0
 private void HandleIOWrite(Loop loop, IOWatcher watcher, int revents)
 {
     HandleWrite ();
 }
Example #22
0
 private void HandleTimeoutEvent(Loop loop, TimerWatcher watcher, EventTypes revents)
 {
     if (Expires <= DateTime.UtcNow) {
         if (TimedOut != null)
             TimedOut (this, EventArgs.Empty);
         Close ();
     }
 }
Example #23
0
 public TimerWatcher(TimeSpan repeat, Loop loop, TimerWatcherCallback callback)
     : this(TimeSpan.Zero, repeat, loop, callback)
 {
 }
Example #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 ();
        }
Example #25
0
 private void OnWantPoll(Loop loop, AsyncWatcher watcher, EventTypes revents)
 {
     if (eio_poll () == -1) {
         Console.WriteLine ("OnWantPoll: starting idle watcher");
         idle_watcher.Start ();
     }
 }
Example #26
0
 internal Watcher(Loop loop)
 {
     Loop = loop;
     gc_handle = GCHandle.Alloc (this);
 }
Example #27
0
 public Context()
 {
     Loop = new Loop ();
     Eio = new EioContext (Loop);
 }
Example #28
0
 private void HandleIORead(Loop loop, IOWatcher watcher, int revents)
 {
     try {
         HandleRead ();
     } catch (Exception e) {
         Close ();
     }
 }
Example #29
0
 public IOLoop()
 {
     Synchronize = true;
     loop = new ManagedLoop(this);
 }
Example #30
0
 private void HandlePrepareEvent(Loop loop, PrepareWatcher watcher, EventTypes revents)
 {
     if (!running) {
        loop.Unloop (UnloopType.All);
        prepare_watcher.Stop ();
         }
 }