Exemple #1
0
 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()));
 }
Exemple #2
0
        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];
        }
Exemple #3
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);
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        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;
        }
Exemple #6
0
 public static object AddWatch(OSHandle handle, WatchEventKind events, 
     WatchHandler handler)
 {
     return Native.Factory.GetLoop().AddWatch(handle, events, handler);
 }
Exemple #7
0
        private void OnPingReceived(object source, OSHandle handle, 
                                    WatchEventKind events)
        {
            lock(olock)
            {
                if(m_disposed)
                    throw new ObjectDisposedException("this");

                Dispatch();
            }
        }
Exemple #8
0
 public WatchEvent(OSHandle handle, WatchEventKind events)
 {
     Handle = handle;
     Events = events;
 }