How RWLock works
masterAn RWLock (Read-Write Lock) manages two types of locks: one for read-only operations and one for writing.
- Reader Lock: Multiple reader tasks can hold the lock simultaneously, provided no writer holds the lock.
- Writer Lock: This lock is exclusive; only one coroutine can hold it at a time.
When to use it: Use an RWLock when data is read frequently but modified infrequently. If updates are frequent, the performance benefits of concurrency will be lost as the lock will spend most of its time in exclusive write mode.