Commit 2534c95
tasks: create taskResult to be returned by Drain
Before this patch, the workerpool would keep a reference to the task
struct even after its task func it has completed to provide the
resulting error (if any) when Drain() is called. Since the task struct
has a reference to the user-provided provided task func, the task func
cannot be garbage collected until Drain() is called. This could be
problematic as (1) the number of task is unbounded and (2) the
workerpool has no control over the memory used by the task func.
This patch introduce a taskResult struct satisfying the Task interface
that doesn't keep a reference to the task func.
Signed-off-by: Alexandre Perrin <[email protected]>1 parent dfc7446 commit 2534c95
2 files changed
+14
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | | - | |
38 | | - | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | | - | |
41 | | - | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | | - | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
0 commit comments