Below is an Actor implementation of a read priority solution to the readers writers problem:
ReadPriority[aDatabase:*ReadersWriter*]:*ReadersWriterManager* // Invariant: **Nonempty** #writing# ⇨ **IsEmpty** #reading# **Locals**(Queue(#writersQ#, #readersQ#), Crowd(#reading#), AtMostOne(#writing#)), **Handlers**( ⟦scheduler⟧ ↦ **As** myScheduler, // myScheduler facet of this manager upgrade[newVersion] ↦ (**CancellAll** #readersQ# **and** #writersQ# **and** #reading# **and** #writing# **for** **Become** newVersion) myScheduler **implements** *ReadersWriter* **Handlers**( read[aQuery] ↦ **Enqueue** #readersQ# **when** **Nonempty** #writing# **or** #writersQ# **or** #readersQ# **for** aDatabase.read[aQuery] **thru** #reading# **permit** #readersQ# **afterward** **Permit** #writersQ# **when** **IsEmpty** #reading# **else** #readersQ# **when** **IsEmpty** #writersQ#, write[anUpdate] ↦ **Enqueue** #writersQ# **when** **Nonempty** #reading# **or** #readersQ# **or** #writing# **or** #writersQ# **for** aDatabase.write[anUpdate] **thru** #writing# **afterward** **Permit** #readersQ# **else** #writersQ#)▮
Below is an Actor implementation of a read priority solution to the readers writers problem: