synceddata

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: GPL-3.0 Imports: 1 Imported by: 1

README

synceddata

GoDoc

Package synceddata implements simple data types that are protected for concurrent use. Currently, the package only contains a simple Counter, but will be extended in the future.

Counter

Counter provides a simple counting interface that's made thread safe through use of a Mutex. Several methods are implemented to do typical functions.

Use:

include "fmt"
include "github.com/davexre/synceddata"

func main() {
	var myCounter synceddata.Counter

	myCounter.Incr()
	myCounter.Incr()
	myCounter.Decr()

	fmt.Printf("Who's number %!(NOVERB)v?\n", myCounter.Read())

	myCounter.Set(6)
	myCounter.Incr()

	fmt.Printf("%!(NOVERB)v is my lucky number!\n", myCounter.Read())
}

Readme created from Go doc with goreadme

Documentation

Overview

Package synceddata implements simple data types that are protected for concurrent use. Currently, the package only contains a simple Counter, but will be extended in the future.

Counter

Counter provides a simple counting interface that's made thread safe through use of a Mutex. Several methods are implemented to do typical functions.

Use:

include "fmt"
include "github.com/davexre/synceddata"

func main() {
	var myCounter synceddata.Counter

	myCounter.Incr()
	myCounter.Incr()
	myCounter.Decr()

	fmt.Printf("Who's number %v?\n", myCounter.Read())

	myCounter.Set(6)
	myCounter.Incr()

	fmt.Printf("%v is my lucky number!\n", myCounter.Read())
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter provides a simple counting interface that's made thread safe through use of a Mutex. Several methods are implemented to do typical functions.

func (*Counter) Decr

func (c *Counter) Decr()

func (*Counter) Incr

func (c *Counter) Incr()

func (*Counter) Read

func (c *Counter) Read() int

func (*Counter) Set

func (c *Counter) Set(i int)

Jump to

Keyboard shortcuts

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