You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0306-actors.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -308,11 +308,11 @@ Reentrancy means that execution of asynchronous actor-isolated functions may "in
308
308
Interleaving executions still respect the actor's "single-threaded illusion", i.e., no two functions will ever execute *concurrently* on any given actor. However they may *interleave* at suspension points. In broad terms this means that reentrant actors are *thread-safe* but are not automatically protecting from the "high level" kinds of races that may still occur, potentially invalidating invariants upon which an executing asynchronous function may be relying on. To further clarify the implications of this, let us consider the following actor, which thinks of an idea and then returns it, after telling its friend about it.
309
309
310
310
```swift
311
-
actorPerson {
311
+
actorDecisionMaker {
312
312
let friend: Friend
313
313
314
314
// actor-isolated opinion
315
-
var opinion: Judgment= .noIdea
315
+
var opinion: Decision= .noIdea
316
316
317
317
functhinkOfGoodIdea() async-> Decision {
318
318
opinion = .goodIdea// <1>
@@ -328,13 +328,13 @@ actor Person {
328
328
}
329
329
```
330
330
331
-
In the example above the `Person` can think of a good or bad idea, shares that opinion with a friend, and returns that opinion that it stored. Since the actor is reentrant this code is wrong and will return an arbitrary opinion if the actor begins to think of a few ideas at the same time.
331
+
In the example above the `DecisionMaker` can think of a good or bad idea, shares that opinion with a friend, and returns that opinion that it stored. Since the actor is reentrant this code is wrong and will return an arbitrary opinion if the actor begins to think of a few ideas at the same time.
332
332
333
333
This is exemplified by the following piece of code, exercising the `decisionMaker` actor:
334
334
335
335
```swift
336
-
let goodThink =detach { awaitperson.thinkOfGoodIdea() } // runs async
337
-
let badThink =detach { awaitperson.thinkOfBadIdea() } // runs async
336
+
let goodThink =detach { awaitdecisionMaker.thinkOfGoodIdea() } // runs async
337
+
let badThink =detach { awaitdecisionMaker.thinkOfBadIdea() } // runs async
338
338
339
339
let shouldBeGood =await goodThink.get()
340
340
let shouldBeBad =await badThink.get()
@@ -372,7 +372,7 @@ If we take the example from the previous section and use a non-reentrant actor,
372
372
// assume non-reentrant
373
373
actorDecisionMaker {
374
374
let friend: DecisionMaker
375
-
var opinion: Judgment= .noIdea
375
+
var opinion: Decision= .noIdea
376
376
377
377
functhinkOfGoodIdea() async-> Decision {
378
378
opinion = .goodIdea
@@ -392,7 +392,7 @@ However, non-entrancy can result in deadlock if a task involves calling back int
0 commit comments