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)); }
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)); }
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)); }
public EioContext(Loop parent) { eioHandlerCb = EioHandler; outstanding = new ConcurrentQueue<Action> (); pulse = new AsyncWatcher (parent, eioHandlerCb); pulse.Start (); }
public IOLoop() { evloop = Loop.CreateDefaultLoop (0); prepare_watcher = new PrepareWatcher (evloop, HandlePrepareEvent); prepare_watcher.Start (); }
internal Watcher(Loop loop) { Loop = loop; unmanaged_callback = new UnmanagedWatcherCallback (UnmanagedCallbackHandler); unmanaged_callback_ptr = Marshal.GetFunctionPointerForDelegate (unmanaged_callback); }
static EioContext() { eioLoop = new Loop (); manos_init (eioLoop.Handle); eioHandlerThread = new Thread (EioHandler); eioHandlerThread.IsBackground = true; eioHandlerThread.Start (); }
public IOLoop() { evloop = Loop.CreateDefaultLoop (0); eio = new Libeio.Libeio (); // eio.Initialize (evloop); libmanos_data = manos_init (evloop.Handle); }
public IOLoop() { evloop = Loop.CreateDefaultLoop (0); eio = new Libeio.Libeio (); eio.Initialize (evloop); prepare_watcher = new PrepareWatcher (evloop, HandlePrepareEvent); prepare_watcher.Start (); }
public CheckWatcher(Loop loop, CheckWatcherCallback callback) : base(loop) { this.callback = callback; unmanaged_watcher = new UnmanagedCheckWatcher (); unmanaged_watcher.callback = CallbackFunctionPtr; InitializeUnmanagedWatcher (unmanaged_watcher); }
public PrepareWatcher(Loop loop, PrepareWatcherCallback callback) : base(loop) { this.callback = callback; unmanaged_watcher = new UnmanagedPrepareWatcher (); unmanaged_watcher.callback = unmanaged_callback_ptr; InitializeUnmanagedWatcher (unmanaged_watcher); }
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); }
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); }
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 (); */ }
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)); } }
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 (); } }
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)); } }
private void HandleTimeout(Loop loop, TimerWatcher timeout, EventTypes revents) { Timeout t = (Timeout) timeout.UserData; AppHost.RunTimeout (t); if (!t.ShouldContinueToRepeat ()) timeout.Stop (); }
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 (); }
private void HandleIORead(Loop loop, IOWatcher watcher, int revents) { HandleRead (); }
private void HandleIOWrite(Loop loop, IOWatcher watcher, int revents) { HandleWrite (); }
private void HandleTimeoutEvent(Loop loop, TimerWatcher watcher, EventTypes revents) { if (Expires <= DateTime.UtcNow) { if (TimedOut != null) TimedOut (this, EventArgs.Empty); Close (); } }
public TimerWatcher(TimeSpan repeat, Loop loop, TimerWatcherCallback callback) : this(TimeSpan.Zero, repeat, loop, callback) { }
private void HandleIOWriteEvent(Loop loop, IOWatcher watcher, EventTypes revents) { // Happens after a close if (handle == IntPtr.Zero) return; Expires = DateTime.UtcNow + TimeOut; HandleWrite (); }
private void OnWantPoll(Loop loop, AsyncWatcher watcher, EventTypes revents) { if (eio_poll () == -1) { Console.WriteLine ("OnWantPoll: starting idle watcher"); idle_watcher.Start (); } }
internal Watcher(Loop loop) { Loop = loop; gc_handle = GCHandle.Alloc (this); }
public Context() { Loop = new Loop (); Eio = new EioContext (Loop); }
private void HandleIORead(Loop loop, IOWatcher watcher, int revents) { try { HandleRead (); } catch (Exception e) { Close (); } }
public IOLoop() { Synchronize = true; loop = new ManagedLoop(this); }
private void HandlePrepareEvent(Loop loop, PrepareWatcher watcher, EventTypes revents) { if (!running) { loop.Unloop (UnloopType.All); prepare_watcher.Stop (); } }