juju / mutex

Provides a named machine level mutex shareable between processes.
Other
27 stars 11 forks source link

Initial import of working mutex. #1

Closed howbazaar closed 8 years ago

howbazaar commented 8 years ago

Tested on linux, my mac book air, and on windows 10.

howbazaar commented 8 years ago

Need to add a test for different named locks not interfering.

davecheney commented 8 years ago

Looks pretty good to me, but I want to see the API surface reduced, specifically I want to see the error values unexported.

howbazaar commented 8 years ago

Key rationale to have an Acquirer interface is to be able to mock out the Mutex. To have something that wants a mutex.Acquirer, but doesn't actually want to interact with the system.

I have removed the two ways to do things, and stopped exporting errLocked.

I do still think it is valuable though to have ErrTimeout and ErrCancelled.exported.

davecheney commented 8 years ago

Key rationale to have an Acquirer interface is to be able to mock out the Mutex. To have something that wants a mutex.Acquirer, but doesn't actually want to interact with the system.

What is the requirement to mock a mutex? If you want to have a dummy mutex then make up a random spec, heck write a testing helper, func UniqueSpec() Spec, that does it for you.