ForksProvider

libretto.examples.diningPhilosophers.ForksProvider$
opaque object ForksProvider extends Forks

Implements Forks. Internally, it represents a fork as a lock from the core library. (Note that the Lock from the core library is not a primitive itself, but is implemented using other primitives. Racing plays a key role in that implementation.)

Attributes

Graph
Supertypes
trait Forks
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Type members

Types

override opaque type HeldFork

A fork that has been successfully picked up and can be used. It represents exclusive access to a fork.

A fork that has been successfully picked up and can be used. It represents exclusive access to a fork.

Attributes

override opaque type SharedFork

Interface to a fork. The fork itself may be shared among multiple philosophers, in which case multiple SharedFork interfaces are created for one "physical" fork. These SharedForks then have to coordinate when accessing the underlying "physical" fork. Once SharedFork is successfully picked up from the table (see tryPickUp), the holder of the resulting HeldFork can use it to eat.

Interface to a fork. The fork itself may be shared among multiple philosophers, in which case multiple SharedFork interfaces are created for one "physical" fork. These SharedForks then have to coordinate when accessing the underlying "physical" fork. Once SharedFork is successfully picked up from the table (see tryPickUp), the holder of the resulting HeldFork can use it to eat.

Attributes

Value members

Concrete methods

override def heldForkReadiness: Positive[HeldFork]

Ability of HeldFork to

Ability of HeldFork to

  • signal readiness (when picked up or done being used).
  • defer readiness by awaiting a Done signal.

Attributes

Definition Classes
override def letGo: SharedFork -⚬ Done

Gives up access to the fork.

Gives up access to the fork.

Attributes

Definition Classes
override def putDown: HeldFork -⚬ SharedFork

Releases the fork so that it can be acquired by others.

Releases the fork so that it can be acquired by others.

Attributes

Definition Classes
override def tryPickUp: SharedFork -⚬ HeldFork |+| SharedFork

Attempts to pick up a shared fork. If successful, outputs HeldFork on the left. Does not wait for the shared fork to become available. If it is unavailable, outputs SharedFork on the right.

Attempts to pick up a shared fork. If successful, outputs HeldFork on the left. Does not wait for the shared fork to become available. If it is unavailable, outputs SharedFork on the right.

Attributes

Definition Classes