eventfd

package
v0.0.0-...-ce94876 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2019 License: MIT, BSD-2-Clause Imports: 3 Imported by: 0

README

Eventfd

A wrapper around eventfd().

Installation

Download and install eventfd

go get github.com/sahne/eventfd

Usage

package main

import (
	"log"
	"github.com/sahne/eventfd"
)

func main() {
	efd, err := eventfd.New()
	if err != nil {
		log.Fatalf("Could not create EventFD: %v", err)
	}
	/* TODO: register fd at kernel interface (for example cgroups memory watcher) */
	/* listen for new events */
	for {
		val, err := efd.ReadEvents()
		if err != nil {
			log.Printf("Error while reading from eventfd: %v", err)
			break
		}
	}
}

Documentation

Index

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
}

func New

func New() (*EventFD, error)

Create a new EventFD.

func (*EventFD) Close

func (e *EventFD) Close() error

Close the eventfd

func (*EventFD) Fd

func (e *EventFD) Fd() int

Returns the filedescriptor which is internally used

func (*EventFD) Read

func (e *EventFD) Read(p []byte) (int, error)

Read events from Eventfd. p should be at max 8 bytes. * Returns the number of read bytes or 0 and error is set.

func (*EventFD) ReadEvents

func (e *EventFD) ReadEvents() (uint64, error)

Read events into a uint64 and return it. Returns 0 and error * if an error occured

func (*EventFD) Write

func (e *EventFD) Write(p []byte) (int, error)

Write bytes to eventfd. Will be added to the current * value of the internal uint64 of the eventfd().

func (*EventFD) WriteEvents

func (e *EventFD) WriteEvents(val uint64) error

Write a uint64 to eventfd. Value will be added to current value * of the eventfd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL