public bool HandleSocketEvents(int numEvents) { bool enqueuedEvent = false; foreach (var socketEvent in new ReadOnlySpan <Interop.Sys.SocketEvent>(Buffer, numEvents)) { if (_handleToContextMap.TryGetValue(socketEvent.Data, out SocketAsyncContextWrapper contextWrapper)) { SocketAsyncContext context = contextWrapper.Context; if (context.PreferInlineCompletions) { context.HandleEventsInline(socketEvent.Events); } else { Interop.Sys.SocketEvents events = context.HandleSyncEventsSpeculatively(socketEvent.Events); if (events != Interop.Sys.SocketEvents.None) { _eventQueue.Enqueue(new SocketIOEvent(context, events)); enqueuedEvent = true; } } } } return(enqueuedEvent); }
private bool TryRegister(SafeCloseSocket socket, Interop.Sys.SocketEvents current, Interop.Sys.SocketEvents events, IntPtr handle, out Interop.Error error) { if (current == events) { error = Interop.Error.SUCCESS; return(true); } error = Interop.Sys.TryChangeSocketEventRegistration(_port, socket, current, events, handle); return(error == Interop.Error.SUCCESS); }
public bool TryRegister(int fileDescriptor, Interop.Sys.SocketEvents current, Interop.Sys.SocketEvents events, GCHandle handle, out Interop.Error error) { if (current == events) { error = Interop.Error.SUCCESS; return(true); } error = Interop.Sys.TryChangeSocketEventRegistration(_port, fileDescriptor, current, events, (IntPtr)handle); return(error == Interop.Error.SUCCESS); }
public bool TryRegister(SafeCloseSocket socket, Interop.Sys.SocketEvents current, Interop.Sys.SocketEvents events, GCHandle handle, out Interop.Error error) { if (current == events) { error = Interop.Error.SUCCESS; return(true); } // // @TODO: work out a better way to handle this. For now, just do the "dangerous" thing; this is called // from SafeCloseSocket.ReleaseHandle, so it can't access the file descriptor in the normal way. // int fd = (int)socket.DangerousGetHandle(); error = Interop.Sys.DangerousTryChangeSocketEventRegistration(_port, fd, current, events, (IntPtr)handle); return(error == Interop.Error.SUCCESS); }
public SocketIOEvent(SocketAsyncContext context, Interop.Sys.SocketEvents events) { Context = context; Events = events; }
public bool TryRegister(SafeCloseSocket socket, Interop.Sys.SocketEvents current, Interop.Sys.SocketEvents events, out Interop.Error error) { Debug.Assert(WasAllocated, "Expected WasAllocated to be true"); return(_engine.TryRegister(socket, current, events, _handle, out error)); }