common

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package common provides non-specific helpers, such as parallelism management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WaitingGroupMap

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

WaitingGroupMap is a synchronisation tool for goroutines. It enables several goroutines to wait for other goroutines in a specific "room".

After joining a room, a goroutine can broadcast or wait for events. To avoid memory leaks, always call Unjoin when leaving a goroutine.

See group_test.go for some examples.

func NewWaitingGroupMap

func NewWaitingGroupMap() *WaitingGroupMap

NewWaitingGroupMap returns a ready to use WaitingGroupMap.

func (*WaitingGroupMap) Broadcast

func (g *WaitingGroupMap) Broadcast(room string, value interface{})

Broadcast emits a message to every member of the room, including the sender.

func (*WaitingGroupMap) Close

func (g *WaitingGroupMap) Close(room string)

Close removes the room from the current WaitingGroupMap, closing all opened channels, and clearing oldMessages.

func (*WaitingGroupMap) CloseAll

func (g *WaitingGroupMap) CloseAll()

CloseAll clears every available room in the current WaitingGroupMap.

func (*WaitingGroupMap) Join

func (g *WaitingGroupMap) Join(room string) (listen chan interface{}, oldMessages []interface{}, newRoom bool)

Join permits the current goroutine to join a room. It returns the listenning channel and a slice containing messages already sent by other members of the room. The room is automatically created if unknown.

func (*WaitingGroupMap) Unjoin

func (g *WaitingGroupMap) Unjoin(room string, i chan interface{})

Unjoin remove the given chan from the current room, freeing memory if needed. If there is nobody remaining in the room, it is destroyed by calling Close.

Jump to

Keyboard shortcuts

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