Skip to content

Instantly share code, notes, and snippets.

@simonask
Created February 12, 2009 12:29
Show Gist options
  • Save simonask/62601 to your computer and use it in GitHub Desktop.
Save simonask/62601 to your computer and use it in GitHub Desktop.
Mutexed: class {
.initialize: [closure] {
.closure: closure
.mutex: Mutex
}
.(): [*args] {
.mutex.lock
.closure(*args)
.mutex.unlock
}
}
foo: Mutexed [muh] {
.n: .n? || 0
.n: .n + 1
print("in order! #{.n}")
}
foo // in order! 1
foo // in order! 2
foo // in order! 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment