Skip to content

Commit

Permalink
try to fix multi-threading word rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yong-zhi committed Oct 15, 2024
1 parent 69ea810 commit 54c8687
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/strategy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function wordsoccupancy!(wc)
for i in 1:3
fontsizes = getfontsizes(wc)
success = true
Threads.@threads for j in 1:length(words)
Threads.@threads :static for j in 1:length(words)
success || break
c, sz, ft, θ = words[j], fontsizes[j], fonts[j], angles[j]
img = Render.rendertext(string(c), sz, backgroundcolor=(0, 0, 0, 0), font=ft, border=border)
Expand Down
7 changes: 6 additions & 1 deletion src/wc-method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ function initialize!(wc, i::Integer; backgroundcolor=(0, 0, 0, 0), spacing=getpa
initqtree!(wc, i, backgroundcolor=backgroundcolor, spacing=spacing)
nothing
end
initialize!(wc, ind; kargs...) = fetch.([Threads.@spawn initialize!(wc, i; kargs...) for i in WordCloud.index(wc, ind)]);
function initialize!(wc, ind; kargs...)
Threads.@threads :static for i in index(wc, ind)
initialize!(wc, i; kargs...)
end
nothing
end
function initialize!(wc::WC; maxiter=5, tolerance=0.02)
params = wc.params
weights = wc.weights
Expand Down

0 comments on commit 54c8687

Please sign in to comment.