event_dispatcher

package
v0.0.0-...-6af4cf9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

*

  • @file event_dispatcher.go
  • @brief A simple, machine-local, thread-safe pub/sub event queue and dispatcher for golang.
  • @author Anadian
  • @copyright Copyright 2019 Canosw Permission is hereby granted, free of charge, to any person obtaining a copy of this

software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies

or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,

INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	//## Exported Constants
	//### Errors
	ERROR_CODE_MATCH_ERROR                int64 = 18
	ERROR_CODE_INDEX_OUT_OF_RANGE         int64 = 20
	ERROR_CODE_SUBORDINATE_FUNCTION_ERROR int64 = 4
	ERROR_CODE_INVALID_MATCHKEY_TYPE      int64 = 5
	ERROR_CODE_EVENT_LISTENER_MATCH       int64 = 6
	ERROR_CODE_EVENT_PROCESSING_ERROR     int64 = 7
)
  • Constants

Constants

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(name string, data map[string]interface{}) (return_report error_report.ErrorReport_struct)

NewEvent creates a new event.

func NewEventDispatcher

func NewEventDispatcher(add_times bool, buffered bool) (return_report error_report.ErrorReport_struct)

NewEventDispatcher creates a new event dispatcher.

func NewEventListener

func NewEventListener(key matchkey.MatchKey_struct, async bool, function func(event Event_struct, args ...interface{})) (return_report error_report.ErrorReport_struct)

NewEventListener creates a new event listener.

Types

type EventDispatcher_struct

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

func (*EventDispatcher_struct) AddEventListener

func (event_dispatcher *EventDispatcher_struct) AddEventListener(event_listener EventListener_struct) (return_report error_report.ErrorReport_struct)

AddEventListener adds an event listener to the event dispatcher.

func (*EventDispatcher_struct) ExtractEventByIndex

func (event_dispatcher *EventDispatcher_struct) ExtractEventByIndex(index uint) (return_report error_report.ErrorReport_struct)

ExtractEventByIndex extracts the event at the given index from the events slice, removing it from the slice, and returns it.

func (EventDispatcher_struct) GetEventByIndex

func (event_dispatcher EventDispatcher_struct) GetEventByIndex(index uint) (return_report error_report.ErrorReport_struct)

GetEventByIndex returns a copy of the event, at the given index, in the events slice; it does not modify the event slice.

func (*EventDispatcher_struct) InsertEventAtIndex

func (event_dispatcher *EventDispatcher_struct) InsertEventAtIndex(event Event_struct, index uint) (return_report error_report.ErrorReport_struct)

InsertEventAtIndex inserts the given event into the events slice at the given index.

func (*EventDispatcher_struct) PopEvent

func (event_dispatcher *EventDispatcher_struct) PopEvent() (return_report error_report.ErrorReport_struct)

PopEvent returns the last event in the queue.

func (EventDispatcher_struct) ProcessEvent

func (event_dispatcher EventDispatcher_struct) ProcessEvent(event Event_struct) (return_report error_report.ErrorReport_struct)

ProcessEvent transmits the given event.

func (EventDispatcher_struct) ProcessEvent_Unsafe

func (event_dispatcher EventDispatcher_struct) ProcessEvent_Unsafe(event Event_struct) (return_report error_report.ErrorReport_struct)

ProcessEvent_Unsafe actually transmits the event.

func (EventDispatcher_struct) ProcessEvents

func (event_dispatcher EventDispatcher_struct) ProcessEvents() (return_report error_report.ErrorReport_struct)

ProcessEvents processes all of the events in the queue.

func (*EventDispatcher_struct) PushEvent

func (event_dispatcher *EventDispatcher_struct) PushEvent(event Event_struct) (return_report error_report.ErrorReport_struct)

PushEvent adds an event to the end of the event queue.

func (*EventDispatcher_struct) RemoveEventByIndex

func (event_dispatcher *EventDispatcher_struct) RemoveEventByIndex(index uint) (return_report error_report.ErrorReport_struct)

RemoveEventByIndex removes the event at the given index from the events slice.

func (*EventDispatcher_struct) RemoveEventListenerByStringLiteral

func (event_dispatcher *EventDispatcher_struct) RemoveEventListenerByStringLiteral(string_literal string) (return_report error_report.ErrorReport_struct)

RemoveEventListenerByStringLiteral removeEventListenerByStringLiteral

func (EventDispatcher_struct) ShiftEvent

func (event_dispatcher EventDispatcher_struct) ShiftEvent() (return_report error_report.ErrorReport_struct)

ShiftEvent extracts and returns the first event in the queue.

type EventListener_struct

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

type Event_struct

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

Types, structs, and methods

Jump to

Keyboard shortcuts

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