liveBook · Manning

Rwlock

Also called read–write lock

An RwLock is a synchronization primitive that permits multiple concurrent readers or one exclusive writer to access protected data.

How 2 Manning books explain it

Learn Concurrent Programming with Go

A readers-writer lock is a synchronization lock that permits multiple simultaneous readers while granting writers exclusive access.

How it is used
Improves throughput for read-heavy shared-data access while preserving exclusive updates.
How deep it goes
Explains API use, benchmarks a server scenario, and builds read- and write-preferring implementations from mutexes and condition variables.
Examples
Demonstrates a basketball-event server with periodic writes and thousands of list-copying client handlers, then simulates writer starvation.
What you can do after
Build it from scratch with counters and mutexes, and apply Go’s sync.RWMutex to separate read and write critical sections.

Read how Learn Concurrent Programming with Go explains rwlock →

Rust Web Development

A read-write lock is a synchronization primitive that allows multiple readers or exclusive access for a writer to shared data.

How it is used
Protects shared question data in a multithreaded REST API while allowing concurrent reads.
How deep it goes
Shows Tokio lock setup and awaited reads, but leaves write-lock operations undeveloped.
Examples
Uses a question store read by GET requests and updated by POST or PUT requests.
What you can do after
Apply Tokio’s RwLock to share and read a REST API’s question store across tasks.

Read how Rust Web Development explains rwlock →

Also covered in

What to know first

Related concepts

Questions about rwlock

What is rwlock?

An RwLock is a synchronization primitive that permits multiple concurrent readers or one exclusive writer to access protected data.

Which Manning books explain rwlock?

Learn Concurrent Programming with Go and Rust Web Development.

What should I know before learning rwlock?

Manning books that teach rwlock usually introduce locking, critical section, race condition and deadlock first.

What is the difference between rwlock and mutex?

An RwLock is a synchronization primitive that permits multiple concurrent readers or one exclusive writer to access protected data. A mutex is a synchronization primitive that provides controlled exclusive access to shared data or a protected operation, admitting only one thread at a time.

What is rwlock a kind of?

Rwlock is a kind of locking. Locking is a synchronization technique that controls concurrent access to a shared resource or protected operation.

What are the parts of rwlock?

Rwlock includes hash map.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.