WEBVTT

00:00:00.500 --> 00:00:02.544
The shelf is one module of several.

00:00:03.444 --> 00:00:05.007
Policy holds the rules.

00:00:05.905 --> 00:00:07.637
Members holds who is borrowing.

00:00:08.535 --> 00:00:10.111
Loans holds the loan book.

00:00:11.009 --> 00:00:12.676
Branches holds the shelves.

00:00:13.575 --> 00:00:16.830
Each has its own sealed memory, and all of it hangs from one

00:00:16.843 --> 00:00:17.285
root.

00:00:18.184 --> 00:00:19.551
This is the owning tree.

00:00:20.450 --> 00:00:22.051
It says where memory lives.

00:00:22.950 --> 00:00:24.877
Lending needs all of them at once.

00:00:25.775 --> 00:00:26.895
So we add Desk.

00:00:27.793 --> 00:00:31.413
Desk has public functions and code, and no memory of its own.

00:00:32.312 --> 00:00:33.926
It is not in the tree at all.

00:00:34.825 --> 00:00:38.614
Desk calls the public functions of Policy, Members, Branches

00:00:38.705 --> 00:00:39.642
and Loans.

00:00:40.541 --> 00:00:43.067
This is the second drawing, the call graph.

00:00:43.965 --> 00:00:46.713
It is wired once at startup, in the root.

00:00:47.611 --> 00:00:49.356
The two drawings are separate.

00:00:50.254 --> 00:00:53.353
Owning decides where memory lives and when it is removed.

00:00:54.252 --> 00:00:56.192
Calling decides who talks to whom.

00:00:58.333 --> 00:00:59.739
A member borrows a drill.

00:01:00.639 --> 00:01:03.256
The public canister method checks who's allowed to make the

00:01:03.270 --> 00:01:05.249
request and supplies today's date.

00:01:06.147 --> 00:01:08.921
Then it opens a write frame on the root and calls Desk.

00:01:09.819 --> 00:01:12.319
Desk and the modules it calls share that frame.

00:01:13.217 --> 00:01:15.379
Desk asks before it changes anything.

00:01:16.277 --> 00:01:18.465
Policy allows three loans per member.

00:01:19.363 --> 00:01:21.512
Members says five-oh-one holds two.

00:01:22.410 --> 00:01:24.376
Branches has a drill on the shelf.

00:01:25.275 --> 00:01:27.072
Loans has room for another entry.

00:01:27.970 --> 00:01:30.210
Every check passes before the first write.

00:01:31.108 --> 00:01:32.124
Now the writes.

00:01:33.022 --> 00:01:36.642
Each one is a call to a public function, and each module changes

00:01:36.655 --> 00:01:37.762
only its own memory.

00:01:38.660 --> 00:01:40.118
The shelf gives up a drill.

00:01:41.017 --> 00:01:42.345
The member's count goes up.

00:01:43.243 --> 00:01:46.915
The loan book opens loan seven, due on day one-fourteen.

00:01:47.814 --> 00:01:49.428
The same member asks again.

00:01:50.327 --> 00:01:51.993
Desk asks Members first.

00:01:52.892 --> 00:01:54.116
Three is the limit.

00:01:55.014 --> 00:01:57.293
Desk stops there and answers with the reason.

00:01:58.191 --> 00:02:01.121
No write was made, so there is nothing to undo.

00:02:03.267 --> 00:02:05.050
One feature leaves the canister.

00:02:05.951 --> 00:02:10.026
On day one-twenty, loan five is fifteen days late, and the fee

00:02:10.039 --> 00:02:12.058
is charged by a payments canister.

00:02:12.956 --> 00:02:16.719
First frame: Loans marks loan five as charging and hands back

00:02:16.732 --> 00:02:17.696
plain values.

00:02:18.594 --> 00:02:19.792
The frame closes.

00:02:20.690 --> 00:02:22.761
Then the call leaves, and we wait.

00:02:23.659 --> 00:02:27.344
When the answer returns, a new frame opens and Loans records

00:02:27.357 --> 00:02:28.008
the result.

00:02:28.907 --> 00:02:31.693
Nothing borrowed from the first frame is carried across the

00:02:31.706 --> 00:02:32.162
wait.

