liveBook · Manning

Arbitrator

As explained in Learn Concurrent Programming with Go

An arbitrator is a coordination component that controls access to shared resources by suspending requests until the required resources are available.

An arbitrator coordinates access to shared resources by granting a request only when every required resource is available. Otherwise, it suspends the goroutine until another operation releases resources, preventing deadlocks caused by partial acquisition. section 11.2.2

Coordinating bank transfers

A transfer requests both its source and target accounts through the arbitrator. Only after both are reserved does it subtract from the source and add to the target, then releases both accounts.

Figure 11.12 Using a condition variable to suspend goroutines when accounts are unavailable

Diagram showing how a condition variable suspends goroutines while accounts are unavailable. section 11.2.2

How Learn Concurrent Programming with Go covers it

How deep it goes
Explains construction and locking steps with condition-variable code, stopping short of implementing the full banker’s algorithm.
Examples
Uses concurrent money transfers across named bank accounts, with runnable Go listings for locking, unlocking, and orchestration.
What you can do after
Build a Go arbitrator that reserves all requested accounts before allowing a transfer to proceed.
How it connects
Connects deadlock avoidance with goroutines, mutexes, condition variables, and the banker’s algorithm.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Concurrent Programming with Go. The section links point to the parts of the book it draws on.