Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (7 sloc) 319 Bytes
package semaphore
import "runtime"
type Semaphore uint32
func (this *Semaphore) P() { runtime.Semacquire((*uint32)(this)) }
func (this *Semaphore) V() { runtime.Semrelease((*uint32)(this)) }
func (this *Semaphore) Turnstile() { this.P(); this.V() }
func (this *Semaphore) Do(do func()) { this.P(); do(); this.V() }