diff options
| author | Shulhan <ms@kilabit.info> | 2023-06-27 01:59:03 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-07-01 17:23:26 +0700 |
| commit | 1623f171f048a0580474a41832dcdf409f63c0fe (patch) | |
| tree | abbf743f054cf7afa630c28c46b57613fa97a10a /lib/net/poll_event_linux.go | |
| parent | aceb4b118bbb76acb991256261d1c7dc7d2868a1 (diff) | |
| download | pakakeh.go-1623f171f048a0580474a41832dcdf409f63c0fe.tar.xz | |
lib/net: implement generic PollEvent
The PollEvent contains file descriptor and the underlying event
based on OS, unix.EpollEvent on Linux or unix.Kevent_t on BSD.
The Poll interface provides two APIs to works with PollEvent,
WaitReadEvents that return list of PollEvent ready for read, and
ReregisterEvent to register the event back to poll (only for Linux).
Diffstat (limited to 'lib/net/poll_event_linux.go')
| -rw-r--r-- | lib/net/poll_event_linux.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/net/poll_event_linux.go b/lib/net/poll_event_linux.go new file mode 100644 index 00000000..69e8ef14 --- /dev/null +++ b/lib/net/poll_event_linux.go @@ -0,0 +1,22 @@ +// Copyright 2023, Shulhan <ms@kilabit.info>. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux + +package net + +import "golang.org/x/sys/unix" + +type pollEvent struct { + fd int32 + event unix.EpollEvent +} + +func (pe *pollEvent) Descriptor() uint64 { + return uint64(pe.fd) +} + +func (pe *pollEvent) Event() any { + return pe.event +} |
