FAST 2021 Demo
Report a defect
|
Request feature
Material used for F.A.S.T 2021 Demo in the Constant Refinement and Continuing Progress at Instantiations presentation.
- The code is licensed under MIT.
- The documentation is licensed under CC BY-SA 4.0.
- Install VA Smalltalk 10.0.1 or newer.
- Install Tonel support in your development image following this guide.
- Clone this repository.
- The easiest and recommended approach is to install it via a script:
| loader path |
path := (CfsPath named: '<insert path to root fast2021-futures-demo-vast local repo here>').
loader := TonelLoader readFromPath: path.
loader
beUnattended; "do not prompt and use all defaults"
useGitVersion.
loader loadAllMapsWithRequiredMaps.
Or you can load the Configuration Map FAST 2021 - Demo Runtime
from the context menu of the Configuration Maps Browser: "Import"
-> "Load Configuration Maps from Tonel repository..."
-> select path to root fast2021-futures-demo-vast
local repo. This will open a dialog and will use convenient defaults for the load. Refer to its documentation for more details.
Here are some of the examples used during the demo:
Futures - Basic
"A Future represents the completion of a computation."
| computeFactorialFuture computeFactorialPlus3Future computeFactorialPlus5Future |
computeFactorialFuture := EsFuture on: [5 factorial]. "or [ 5 factorial ] async"
computeFactorialPlus3Future := computeFactorialFuture then: [:factorial | TranscriptTTY default show: (factorial + 3) printString; cr].
computeFactorialPlus5Future := computeFactorialFuture then: [:factorial | TranscriptTTY default show: (factorial + 5) printString; cr].
(EsFuture all: { computeFactorialPlus3Future. computeFactorialPlus5Future. } )
then: [ TranscriptTTY default show: 'I am done!'; cr ]
Futures - Exceptions
((EsFuture on: [Exception signal: 'oh no' "throw error somewhere in the async code" ])
catch: [:exception :stack | TranscriptTTY default show: 'Caught error: ', exception messageText ; cr])
ensure: [TranscriptTTY default show: 'Finished!'; cr]
Promises - Basic
"A promise to complete a future in a later time"
| future promise |
promise := EsPromise new.
future := promise future.
future then: [:number | TranscriptTTY default show: number printString].
promise complete: 42.
Promises - OsProcess
(OsProcessStarter start: #('sleep' '5')) onCompletion
then: [TranscriptTTY default show: 'Process finished' ]
For the demo, checkout the methods #syncProcessCovidData
and #asyncProcessCovidData