mutex

package
v0.0.0-...-9413c1f Latest Latest
Warning

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

Go to latest
Published: May 15, 2015 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package mutex provides a wrapper interface to sync.Mutex that, when built with both "diag" and "mutex" tags (e.g. go build -tags "diag mutex"), will log each Lock() and Unlock() to the diagnostic file or syslog.

Usage ("./foo.go"):

package main

import (
	"github.com/apptimistco/asn/debug"
	"github.com/apptimistco/asn/debug/mutex"
)

var foo struct {
	mutex.Mutex
	...
}

func main() {
	foo.Mutex.Set("foo")
	if false {
		debug.Diag.Redirect("foo.diag")
	}
	foo.Lock()		// line: X
	defer foo.Unlock()
	...
	return			// line: Y
}

build and run,

$ go build -tags "diag mutex" .
$ ./foo

would syslog this at level DEBUG,

foo.go:X: foo lock
foo.go:Y: foo unlock

with the Redirect(), this is printed to the named file instead of syslog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex struct {
	sync.Mutex
	debug.Debug
}

Jump to

Keyboard shortcuts

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