Home
Code
Contact

eventfd for Go


Eventfd Bindings for Go

Eventfd Bindings for Go

eventfd is a lightweight filedescriptor used for lightweight event wait/notify mechanisms for user-space applications and kernel to user-space notifications. For more information on eventfd see

man 2 eventfd

Usage and Installation

Install

Install via

go get github.com/sahne/eventfd

Example 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 for kernel interface (eg: cgroups memory watcher) */

	/* listen for new events */
	for {
		val, err := efd.ReadEvents()
		if err != nil {
			log.Printf("Error while processing event: %v", err)
			break;
		}
		/* TODO: Handle event */
	}
}