Swap
The swap example demonstrates parallel composition. It is more general than parallel assignment.
Factorize
The factorize example shows how to use the basic functionalily of Delta.
Greatest Common Divisor
The gcd example shows first class states.
Quicksort and Heapsort
The quicksort and the heapsort examples demonstrate modules. The main module sort uses the two sort libraries.
The quicksort example also demonstrates parallel composition. Change
the | into ; to see how easy it is to
switch to and from sequential composition.
Dining Philosophers
The dining philosophers example
is Dijkstra’s classic problem and uses the original solution with
semaphores. It demonstrates how threads are run with parallel
composition. Again, change the | into ; to see how easy it is to
switch to and from sequential composition.
Message Streams
Delta features communication channels.
The message loop shows tail recursion in recursive parallel calls. This examples runs with flat memory use.
The message loop bound is a bounded variant.
These examples show the resemblance to sequential communicating processes.
Client Server
This example demonstrates socket programming. It uses tcp messaging in addition to Delta’s internal communication channels.
The server uses paralles composition to run threads for each accepted connection. The exception handling makes the server robust.
The client connects to the server.
Ant Colony
Variation on Rick Hickey’s Ant Colony. Ants collect food in a square world and they communicate with pheromones. File ants contains the ant simulation and file ants world containts the supporting data structures.
The challenge is to use synchronized threads that scale on multicores: * Each ant runs in a thread * All world mutations are atomic and consistent * Each snapshot shows a consistent world
Rick Hickey’s nice solution uses software transactional memory. Delta has no software transactional memory so the solution uses locks.
Each cell in the world has a mutex to make mutations atomic. Rendering is done in a seperate thread that uses one mutex to synchronize with the GUI. When a mutation in the world occurs a message is send to the seperate rendering thread. For the renderer all actions are sequential in time.