Skip to content

Commit 906d13b

Browse files
committed
---
yaml --- r: 22915 b: refs/heads/master c: ac0c8b0 h: refs/heads/master i: 22913: df1da3c 22911: e663af9 v: v3
1 parent cc4ca36 commit 906d13b

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7cb3f3e86a5500ecf40500dc9f6cedabd8e0349e
2+
refs/heads/master: ac0c8b08233b8654aa69a0902bacd7be40072c54
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/task.rs

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,67 @@ unsafe fn atomically<U>(f: fn() -> U) -> U {
585585
}
586586

587587
/****************************************************************************
588-
* Internal
588+
* Spawning & linked failure
589+
*
590+
* Several data structures are involved in task management to allow properly
591+
* propagating failure across linked/supervised tasks.
592+
*
593+
* (1) The "taskgroup_arc" is an arc::exclusive which contains a hashset of
594+
* all tasks that are part of the group. Some tasks are 'members', which
595+
* means if they fail, they will kill everybody else in the taskgroup.
596+
* Other tasks are 'descendants', which means they will not kill tasks
597+
* from this group, but can be killed by failing members.
598+
*
599+
* A new one of these is created each spawn_linked or spawn_supervised.
600+
*
601+
* (2) The "taskgroup" is a per-task control structure that tracks a task's
602+
* spawn configuration. It contains a reference to its taskgroup_arc,
603+
* a reference to its node in the ancestor list (below), a flag for
604+
* whether it's part of the 'main'/'root' taskgroup, and an optionally
605+
* configured notification port. These are stored in TLS.
606+
*
607+
* (3) The "ancestor_list" is a cons-style list of arc::exclusives which
608+
* tracks 'generations' of taskgroups -- a group's ancestors are groups
609+
* which (directly or transitively) spawn_supervised-ed them. Each task
610+
* recorded in the 'descendants' of each of its ancestor groups.
611+
*
612+
* Spawning a supervised task is O(n) in the number of generations still
613+
* alive, and exiting (by success or failure) that task is also O(n).
614+
*
615+
* This diagram depicts the references between these data structures:
616+
*
617+
* linked_________________________________
618+
* ___/ _________ \___
619+
* / \ | group X | / \
620+
* ( A ) - - - - - - - > | {A,B} {}|< - - -( B )
621+
* \___/ |_________| \___/
622+
* unlinked
623+
* | __ (nil)
624+
* | //| The following code causes this:
625+
* |__ // /\ _________
626+
* / \ // || | group Y | fn taskA() {
627+
* ( C )- - - ||- - - > |{C} {D,E}| spawn(taskB);
628+
* \___/ / \=====> |_________| spawn_unlinked(taskC);
629+
* supervise /gen \ ...
630+
* | __ \ 00 / }
631+
* | //| \__/ fn taskB() { ... }
632+
* |__ // /\ _________ fn taskC() {
633+
* / \/ || | group Z | spawn_supervised(taskD);
634+
* ( D )- - - ||- - - > | {D} {E} | ...
635+
* \___/ / \=====> |_________| }
636+
* supervise /gen \ fn taskD() {
637+
* | __ \ 01 / spawn_supervised(taskE);
638+
* | //| \__/ ...
639+
* |__ // _________ }
640+
* / \/ | group W | fn taskE() { ... }
641+
* ( E )- - - - - - - > | {E} {} |
642+
* \___/ |_________|
643+
*
644+
* "taskgroup" "taskgroup_arc"
645+
* "ancestor_list"
646+
*
589647
****************************************************************************/
590648

591-
/* spawning */
592-
593649
type sched_id = int;
594650
type task_id = int;
595651

@@ -598,8 +654,6 @@ type task_id = int;
598654
type rust_task = libc::c_void;
599655
type rust_closure = libc::c_void;
600656

601-
/* linked failure */
602-
603657
type taskset = send_map::linear::linear_map<*rust_task,()>;
604658

605659
fn new_taskset() -> taskset {

0 commit comments

Comments
 (0)