events

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: BSL-1.0 Imports: 1 Imported by: 2

README

Events

GoDoc Go Report Card

About

This package provides generic event queues and generic events. It is published on https://github.com/vbsw/events.

Copyright 2019, Vitali Baumtrok (vbsw@mailbox.org).

Events is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

Events is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Using Go

Get this project:

$ go get github.com/vbsw/events

Update a local copy:

$ go get -u github.com/vbsw/events

Compile:

$ go install github.com/vbsw/events

Run tests:

$ go test github.com/vbsw/events

Using Git

Get the master branch and all refs of this project:

$ git clone https://github.com/vbsw/events.git

See all tags:

$ git tag -l

See local and remote branches:

$ git branch -a

Checkout other branches than master, for example the development branch:

$ git branch development origin/development
$ git checkout development

See tracked remote branches:

$ git branch -vv

Update all tracked branches and all refs:

$ git fetch

References

Documentation

Overview

Package events provides generic event queues and generic events.

Version 1.0.0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultEvent

type DefaultEvent struct {
	// contains filtered or unexported fields
}

DefaultEvent serves as a template for other events.

func (*DefaultEvent) EventTypeID

func (event *DefaultEvent) EventTypeID() int

EventTypeID returns a value representing the type of the event.

func (*DefaultEvent) TimeStamp

func (event *DefaultEvent) TimeStamp() uint64

TimeStamp returns a value representing the creation time of the event.

type DefaultQueue

type DefaultQueue struct {
	// contains filtered or unexported fields
}

DefaultQueue serves as a template for other event queues.

func (*DefaultQueue) Close

func (queue *DefaultQueue) Close()

Close removes all events from queue. Further posted events are ignored. Next call of NextEvent returns nil.

func (*DefaultQueue) NextEvent

func (queue *DefaultQueue) NextEvent() Event

NextEvent returns the next event in the queue if available, otherwise nil.

func (*DefaultQueue) PostEvent

func (queue *DefaultQueue) PostEvent(event Event)

PostEvent puts an event into queue.

type DefaultSynchronizedQueue

type DefaultSynchronizedQueue struct {
	DefaultQueue
	// contains filtered or unexported fields
}

DefaultSynchronizedQueue serves as a template for other event queues.

func (*DefaultSynchronizedQueue) Close

func (queue *DefaultSynchronizedQueue) Close()

Close removes all events from queue. Further posted events are ignored. Next call of NextEvent returns nil.

func (*DefaultSynchronizedQueue) NextEvent

func (queue *DefaultSynchronizedQueue) NextEvent() Event

NextEvent returns the next event in the queue if available, otherwise nil.

func (*DefaultSynchronizedQueue) PostEvent

func (queue *DefaultSynchronizedQueue) PostEvent(event Event)

PostEvent puts an event into queue.

type Event

type Event interface {
	EventTypeID() int
	TimeStamp() uint64
}

Event is posted into and retrieved from the event queue.

func NewEvent

func NewEvent(eventTypeID int, timeStamp uint64) Event

NewEvent returns a simple event, that may serve as a stub.

type Queue

type Queue interface {
	Close()
	NextEvent() Event
	PostEvent(event Event)
}

Queue holds the events.

func NewQueue

func NewQueue(initialCapacity ...int) Queue

NewQueue returns a simple unsynchronized event queue. Default capacity is 6.

func NewSynchronizedQueue

func NewSynchronizedQueue(initialCapacity ...int) Queue

NewSynchronizedQueue returns a simple synchronized event queue. Default capacity is 6.

Jump to

Keyboard shortcuts

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