nosync

package
v0.0.0-...-b8e9a8a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2015 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

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

Mutex is a dummy which is non-blocking.

func (*Mutex) Lock

func (m *Mutex) Lock()

Lock locks m. It is a run-time error if m is already locked.

func (*Mutex) Unlock

func (m *Mutex) Unlock()

Unlock unlocks m. It is a run-time error if m is not locked.

type Once

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

Once is an object that will perform exactly one action.

func (*Once) Do

func (o *Once) Do(f func())

Do calls the function f if and only if Do is being called for the first time for this instance of Once. In other words, given

var once Once

if once.Do(f) is called multiple times, only the first call will invoke f, even if f has a different value in each invocation. A new instance of Once is required for each function to execute.

Do is intended for initialization that must be run exactly once. Since f is niladic, it may be necessary to use a function literal to capture the arguments to a function to be invoked by Do:

config.once.Do(func() { config.init(filename) })

If f causes Do to be called, it will panic.

If f panics, Do considers it to have returned; future calls of Do return without calling f.

type Pool

type Pool struct {
	New func() interface{}
	// contains filtered or unexported fields
}

A Pool is a set of temporary objects that may be individually saved and retrieved.

Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated.

A Pool is safe for use by multiple goroutines simultaneously.

Pool's purpose is to cache allocated but unused items for later reuse, relieving pressure on the garbage collector. That is, it makes it easy to build efficient, thread-safe free lists. However, it is not suitable for all free lists.

An appropriate use of a Pool is to manage a group of temporary items silently shared among and potentially reused by concurrent independent clients of a package. Pool provides a way to amortize allocation overhead across many clients.

An example of good use of a Pool is in the fmt package, which maintains a dynamically-sized store of temporary output buffers. The store scales under load (when many goroutines are actively printing) and shrinks when quiescent.

On the other hand, a free list maintained as part of a short-lived object is not a suitable use for a Pool, since the overhead does not amortize well in that scenario. It is more efficient to have such objects implement their own free list.

func (*Pool) Get

func (p *Pool) Get() interface{}

Get selects an arbitrary item from the Pool, removes it from the Pool, and returns it to the caller. Get may choose to ignore the pool and treat it as empty. Callers should not assume any relation between values passed to Put and the values returned by Get.

If Get would otherwise return nil and p.New is non-nil, Get returns the result of calling p.New.

func (*Pool) Put

func (p *Pool) Put(x interface{})

Put adds x to the pool.

type RWMutex

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

RWMutex is a dummy which is non-blocking.

func (*RWMutex) Lock

func (rw *RWMutex) Lock()

Lock locks m for writing. It is a run-time error if rw is already locked for reading or writing.

func (*RWMutex) RLock

func (rw *RWMutex) RLock()

RLock locks m for reading. It is a run-time error if rw is already locked for reading or writing.

func (*RWMutex) RUnlock

func (rw *RWMutex) RUnlock()

RUnlock undoes a single RLock call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading.

func (*RWMutex) Unlock

func (rw *RWMutex) Unlock()

Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing.

type WaitGroup

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

WaitGroup is a dummy which is non-blocking.

func (*WaitGroup) Add

func (wg *WaitGroup) Add(delta int)

Add adds delta, which may be negative, to the WaitGroup If the counter goes negative, Add panics.

func (*WaitGroup) Done

func (wg *WaitGroup) Done()

Done decrements the WaitGroup counter.

func (*WaitGroup) Wait

func (wg *WaitGroup) Wait()

Wait panics if the WaitGroup counter is not zero.

Jump to

Keyboard shortcuts

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