Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,15 @@ func (m *opMap) Begin(name string) *opResult {
}

op := opIface.(*opResult)
// someone else doing ops with this key, wait for
// the result
// someone else doing ops with this key, wait for the
// result Note: we are using `op.mu` as a syncing
// primitive to make several threads WAIT. The first
// operation will grab the write-lock. Everyone else
// tries to grab a read-lock as a way of waiting for
// the operation to be finished by the thead that
// grabbed the write-lock. The Read-lock does not need
// to be unlocked, as the operation is never used or
// re-used for anything else from that point.
op.mu.RLock()
if op.success {
return nil
Expand Down