@@ -30,18 +30,11 @@ Functions like [`flip`](@ref), [`reproject`](@ref), [`transform`](@ref), even [`
30
30
using the `apply` framework. Similarly, [`centroid`](@ref), [`area`](@ref) and [`distance`](@ref) have been implemented using the
31
31
[`applyreduce`](@ref) framework.
32
32
33
- ## Docstrings
34
-
35
- ### Functions
36
-
37
33
```@docs; collapse=true, canonical=false
38
34
apply
39
- applyreduce
40
35
```
41
36
42
- =#
43
37
44
- #=
45
38
## What is `apply`?
46
39
47
40
`apply` applies some function to every geometry matching the `Target`
@@ -69,7 +62,7 @@ Be careful making a union across "levels" of nesting, e.g.
69
62
`Union{FeatureTrait,PolygonTrait}`, as `_apply` will just never reach
70
63
`PolygonTrait` when all the polygons are wrapped in a `FeatureTrait` object.
71
64
72
- ## Embedding:
65
+ ### Embedding
73
66
74
67
`extent` and `crs` can be embedded in all geometries, features, and
75
68
feature collections as part of `apply`. Geometries deeper than `Target`
@@ -78,14 +71,30 @@ will of course not have new `extent` or `crs` embedded.
78
71
- `calc_extent` signals to recalculate an `Extent` and embed it.
79
72
- `crs` will be embedded as-is
80
73
81
- ## Threading
74
+ ### Threading
82
75
83
76
Threading is used at the outermost level possible - over
84
77
an array, feature collection, or e.g. a MultiPolygonTrait where
85
78
each `PolygonTrait` sub-geometry may be calculated on a different thread.
86
79
87
80
Currently, threading defaults to `false` for all objects, but can be turned on
88
81
by passing the keyword argument `threaded=true` to `apply`.
82
+
83
+ Threading uses [StableTasks.jl](https://github.com/JuliaFolds2/StableTasks.jl) to provide
84
+ type-stable tasks (base Julia `Threads.@spawn` is not type stable). This is completely cost-free
85
+ and saves some allocations when running multithreaded.
86
+
87
+ The current strategy is to launch 2 tasks for each CPU thread, to provide load balancing. We
88
+ assume Julia will manage these tasks efficiently, and we don't want to run too many tasks
89
+ since each task does have some overhead when it's created. This may need revisiting in the future,
90
+ but it's a pretty easy heuristic to use.
91
+
92
+ ## Implementation
93
+
94
+ Literate.jl source code is below.
95
+
96
+ ***
97
+
89
98
=#
90
99
91
100
"""
0 commit comments