Documentation
¶
Overview ¶
Package eventfd wraps Linux's eventfd(2) syscall.
Index ¶
- type Eventfd
- func (ev Eventfd) Close() error
- func (ev *Eventfd) DisableMMIO()
- func (ev Eventfd) Dup() (Eventfd, error)
- func (ev *Eventfd) EnableMMIO(addr uintptr, ctrl MMIOController)
- func (ev Eventfd) FD() int
- func (ev Eventfd) MMIOAddr() uintptr
- func (ev Eventfd) MMIOWrite(val uint64) error
- func (ev Eventfd) Notify() error
- func (ev Eventfd) Read() (uint64, error)
- func (ev Eventfd) Wait() error
- func (ev Eventfd) Write(val uint64) error
- type MMIOController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Eventfd ¶
type Eventfd struct {
// contains filtered or unexported fields
}
Eventfd represents a Linux eventfd object.
func (*Eventfd) DisableMMIO ¶
func (ev *Eventfd) DisableMMIO()
DisableMMIO undoes the effect of a previous call to EnableMMIO. DisableMMIO cannot be called concurrently with Write, MMIOWrite, or MMIOAddr.
func (*Eventfd) EnableMMIO ¶
func (ev *Eventfd) EnableMMIO(addr uintptr, ctrl MMIOController)
EnableMMIO causes future calls to ev.Write() to use memory-mapped writes to addr, subject to ctrl. EnableMMIO cannot be called concurrently with Write, MMIOWrite, or MMIOAddr.
This feature is used to support KVM ioeventfds. Since this requires that addr is mapped read-only or with no permissions in the host virtual address space (so that writes in host mode fault), it cannot reasonably be Go-managed memory, so it's safe to type as uintptr rather than a pointer.
func (Eventfd) FD ¶
FD returns the underlying file descriptor. Use with care, as this breaks the Eventfd abstraction.
func (Eventfd) MMIOWrite ¶
MMIOWrite is equivalent to Write, but returns an error if the write cannot be implemented by writing to the address set by EnableMMIO. This is primarily useful for testing.
func (Eventfd) Notify ¶
Notify alerts other users of the eventfd. Users can receive alerts by calling Wait or Read.
func (Eventfd) Read ¶
Read blocks until eventfd is non-zero (i.e. someone calls Notify or Write) and returns the value read.
type MMIOController ¶
type MMIOController interface {
// Enabled returns true if writing to the associated MMIO address can
// succeed. This is inherently racy, so if the memory-mapped write faults,
// the eventfd will fall back to writing using a syscall.
Enabled() bool
// Close is called when the associated Eventfd is closed.
Close(ev Eventfd)
}
MMIOController controls eventfd memory-mapped I/O.