View on GitHub

vendingmachine-js

example code from CSP talk

Download this project as a .zip file Download this project as a tar.gz file

Introduction

The code for this talk was inspired from many sources, which are listed in the references of my slides. While the initial examples come straight from Tony Hoare's book, Communicating Sequential Processes, I chose to extend the vending machine motif for pedagogical purposes; to provide minimal working examples that gradually incorporate each fundamental primitive.

Note: Running these examples currently require viewing in Chrome Canary, Firefox Aurora, Safari Nightly or some other browser with experimental ES6 features enabled. Running these examples with your browser's console open allows you to monitor the verbose process log messages.

Example #1

A simple vending machine that accepts a single coin from a customer and then breaks.

See Example #1

Example #2

A simple vending machine that serves two customers and then breaks.

See Example #2

Example #3

A simple vending machine that serves an infinite number of customers.

See Example #3

Example #4

A simple vending machine that offers customers choice between two different candies.

See Example #4

Example #5

A dashboard monitor for a single vending machine and 100 simulated customers.

See Example #5

Example #6

A dashboard monitor for a cluster of vending machines and 2500 simulated customers each.

See Example #6

Example #7

A dashboard monitor demonstrating tuning for back pressure by utilizing buffers.

See Example #7

Example #8

A demonstration of maintaining UI-responsiveness on the same page as the previous dashboard examples.

See Example #8