mutexBuffer

package module
v0.0.0-...-8a3fb22 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2017 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

MutexBuffer

Allow for a single mutex to have a buffer that allows for more than one lock

This allows for a certain number of go routines to access the code at a time

How to Use

package main

import (
  "github.com/Siryu/MutexBuffer"
)

func main() {
// create reference to mutex
// set the size you want the buffer to be
mutex := mutexBuffer.New(3)
// lock a mutex
mutex.Lock()

// insert the code here you want to be restricted to

// unlock a mutex
mutex.Unlock()
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MutexBuffer

type MutexBuffer struct {
	Mutexes  []bool
	RealLock *sync.Mutex
}

MutexBuffer create reference and hold to make a buffered mutex

func New

func New(bufferSize int) (newMutexBuffer *MutexBuffer)

New creates a new mutexBuffer and returns it

func (*MutexBuffer) Lock

func (m *MutexBuffer) Lock()

Lock sets a lock on one of the mutexes

func (*MutexBuffer) SetBuffer

func (m *MutexBuffer) SetBuffer(bufferSize int)

SetBuffer takes in an int that determines the amount of locks

func (*MutexBuffer) Unlock

func (m *MutexBuffer) Unlock() (err error)

Unlock unlocks a lock from the mutexes

Jump to

Keyboard shortcuts

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