public Stream CreateStream(OSHandle handle, bool owns_handle) { if(handle.HandleKind == HandleKind.FD) return new UnixStream((int)handle.Handle, owns_handle); else throw new ArgumentException(String.Format("Handle of type \"{0}\" not supported by {1}", handle.HandleKind, GetType())); }
public override object AddWatch(OSHandle handle, WatchEventKind events, WatchHandler handler) { object[] closure = new object[2]; closure[0] = new EPollSourceID((uint)(int)(IntPtr)handle); closure[1] = handler; poll.AddWatch(handle, events); poll_handlers[(IntPtr)handle] = closure; Console.WriteLine("{0} = {1}", (IntPtr)handle, closure.GetHashCode()); return closure[0]; }
public void UpdateEvents(OSHandle handle, WatchEventKind events) { EPollEvent evt; if(handle.HandleKind != HandleKind.FD) throw new ArgumentException(String.Format("Handle of type \"{0}\" not supported by {1}", handle.HandleKind, GetType())); evt.FD = (int)handle.Handle; evt.EventKind = MapEventsN(events); int r = epoll_ctl(m_fd, EPOLL_CTL_MOD, evt.FD, ref evt); UnixMarshal.ThrowExceptionForLastErrorIf(r); }
public void RemoveWatch(OSHandle handle) { EPollEvent evt; if(handle.HandleKind != HandleKind.FD) throw new ArgumentException(String.Format("Handle of type \"{0}\" not supported by {1}", handle.HandleKind, GetType())); evt.FD = (int)handle.Handle; evt.EventKind = 0; int r = epoll_ctl(m_fd, EPOLL_CTL_DEL, evt.FD, ref evt); UnixMarshal.ThrowExceptionForLastErrorIf(r); m_buffer.Count -= 1; }
public void AddWatch(OSHandle handle, WatchEventKind events) { EPollEvent evt; if(handle.HandleKind != HandleKind.FD) throw new ArgumentException(String.Format("Handle of type \"{0}\" not supported by {1}", handle.HandleKind, GetType())); evt.FD = (int)handle.Handle; evt.EventKind = MapEventsN(events); Console.WriteLine("AddWatch({0})", evt.FD); int r = epoll_ctl(m_fd, EPOLL_CTL_ADD, evt.FD, ref evt); UnixMarshal.ThrowExceptionForLastErrorIf(r); m_buffer.Count += 1; }
public static object AddWatch(OSHandle handle, WatchEventKind events, WatchHandler handler) { return Native.Factory.GetLoop().AddWatch(handle, events, handler); }
private void OnPingReceived(object source, OSHandle handle, WatchEventKind events) { lock(olock) { if(m_disposed) throw new ObjectDisposedException("this"); Dispatch(); } }
public WatchEvent(OSHandle handle, WatchEventKind events) { Handle = handle; Events = events; }