varasto: Index | Files

package mutexmap

import ""


Package Files


type M Uses

type M struct {
    // contains filtered or unexported fields

Think of this as an infinite number of named bathroom stalls. Each named stall can only be occupied by one person. When you TryLock(): a) it won't open if it's already occupied. (because it's locked inside) decide to do something else b) it opens and you get in and the stall gets reserved/locked for you. When you get out

you call the unlock callback you obtained from TryLock() to return the stall for use.

func New Uses

func New() *M

func (*M) Lock Uses

func (n *M) Lock(key string) func()

func (*M) TryLock Uses

func (n *M) TryLock(key string) (func(), bool)

returns false if gate already open/reserved returns true if gate was opened for you. you have to use the returned func to release it

Package mutexmap imports 1 packages (graph) and is imported by 3 packages. Updated 2020-08-22. Refresh now. Tools for package owners.