コード例 #1
0
ファイル: LinuxNative.cs プロジェクト: theojulienne/lucid
 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()));
 }
コード例 #2
0
ファイル: LinuxNative.cs プロジェクト: theojulienne/lucid
        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];
        }
コード例 #3
0
ファイル: EPoll.cs プロジェクト: theojulienne/lucid
        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);
        }
コード例 #4
0
ファイル: EPoll.cs プロジェクト: theojulienne/lucid
        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;
        }
コード例 #5
0
ファイル: EPoll.cs プロジェクト: theojulienne/lucid
        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;
        }
コード例 #6
0
ファイル: Application.cs プロジェクト: theojulienne/lucid
 public static object AddWatch(OSHandle handle, WatchEventKind events, 
     WatchHandler handler)
 {
     return Native.Factory.GetLoop().AddWatch(handle, events, handler);
 }
コード例 #7
0
ファイル: ThreadQueue.cs プロジェクト: theojulienne/lucid
        private void OnPingReceived(object source, OSHandle handle, 
                                    WatchEventKind events)
        {
            lock(olock)
            {
                if(m_disposed)
                    throw new ObjectDisposedException("this");

                Dispatch();
            }
        }
コード例 #8
0
ファイル: WatchEvent.cs プロジェクト: theojulienne/lucid
 public WatchEvent(OSHandle handle, WatchEventKind events)
 {
     Handle = handle;
     Events = events;
 }