MCPcopy Index your code
hub / github.com/goinaction/code / WriteLock

Method WriteLock

chapter7/patterns/semaphore/semaphore.go:234–240  ·  view source on GitHub ↗

WriteLock blocks all reading so the write can happen safely.

()

Source from the content-addressed store, hash-verified

232
233// WriteLock blocks all reading so the write can happen safely.
234func (rw *readerWriter) WriteLock() {
235 // Add 1 to the waitGroup so reads will block
236 rw.write.Add(1)
237
238 // Acquire all the buffers from the semaphore channel.
239 rw.readerControl.Acquire(rw.maxReads)
240}
241
242// WriteUnlock releases the write lock and allows reads to occur.
243func (rw *readerWriter) WriteUnlock() {

Callers 1

performWriteMethod · 0.95

Calls 2

AddMethod · 0.80
AcquireMethod · 0.45

Tested by

no test coverage detected