in pekko-sample-fsm-scala/src/main/scala/sample/DiningHakkers.scala [36:54]
def apply(): Behavior[ChopstickMessage] = available()
// When a Chopstick is taken by a hakker
// It will refuse to be taken by other hakkers
// But the owning hakker can put it back
private def takenBy(
hakker: ActorRef[ChopstickAnswer]): Behavior[ChopstickMessage] = {
Behaviors.receive {
case (ctx, Take(otherHakker)) =>
otherHakker ! Busy(ctx.self)
Behaviors.same
case (_, Put(`hakker`)) =>
available()
case _ =>
// here and below it's left to be explicit about partial definition,
// but can be omitted when Behaviors.receiveMessagePartial is in use
Behaviors.unhandled
}
}