Document the mutex shenanigans used to implement block until ready
This commit is contained in:
parent
f994664130
commit
b3e271bc2a
|
@ -87,6 +87,13 @@ func fdb_future_block_until_ready(f *C.FDBFuture) {
|
|||
return
|
||||
}
|
||||
|
||||
// The mutex here is used as a signal that the callback is complete.
|
||||
// We first lock it, then pass it to the callback, and then lock it
|
||||
// again. The second call to lock won't return until the callback has
|
||||
// fired.
|
||||
//
|
||||
// See https://groups.google.com/forum/#!topic/golang-nuts/SPjQEcsdORA
|
||||
// for the history of why this pattern came to be used.
|
||||
m := &sync.Mutex{}
|
||||
m.Lock()
|
||||
C.go_set_callback(unsafe.Pointer(f), unsafe.Pointer(m))
|
||||
|
|
Loading…
Reference in New Issue