libretto.examples.supermarket

Members list

Concise view

Type members

Classlikes

Our supermarket specializes in the most wanted items in a pandemic, namely toilet paper and beer.

Our supermarket specializes in the most wanted items in a pandemic, namely toilet paper and beer.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Goods.type
object Customers

Attributes

Companion:
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
class Customers[SupermarketImpl <: SupermarketInterface](val supermarket: SupermarketImpl)

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
opaque object Goods extends GoodsProducer with GoodsConsumer

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Goods.type

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Goods.type

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Goods.type
object Supermarket extends StarterApp

In a pandemic, supermarkets are required to limit the number of customers in the store. A way to achieve it is to provide a limited number of shopping baskets and require that each customer entering the store has a shopping basket. When there are no more baskets, an incoming customer has to wait for a previous customer to leave (and return their basket).

In a pandemic, supermarkets are required to limit the number of customers in the store. A way to achieve it is to provide a limited number of shopping baskets and require that each customer entering the store has a shopping basket. When there are no more baskets, an incoming customer has to wait for a previous customer to leave (and return their basket).

This example demonstrates:

  • concurrency
    • customers come and shop concurrently
  • sequencing
    • a customer can shop only after obtaining a basket
    • a customer can use an item only after paying for it
    • ...
  • mutual exclusion
    • limited number of concurrently shopping customers
      • without side-effects on shared synchronization objects (such as semaphores)
  • linear & session types
    • obligation to return a basket enforced before execution
    • the type Shopping is a protocol between the store and the customer

Attributes

Graph
Supertypes
class StarterApp
class StarterAppBase
class Object
trait Matchable
class Any
Self type

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
opaque object baskets

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
baskets.type
opaque object money

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
money.type