Skip to content

Sharing data b/w pool of worker threads ? #170

Answered by vladmandic
uzair004 asked this question in Q&A
Discussion options

You must be logged in to vote

good question - and you found the right problems :)

i'm assuming we're talking about browser environment as nodejs workers are not worth using just yet. instead in nodejs i'd go with process pool instead, but then there is really no sharing and option 3 or 4 are the only options

option 1

assuming array is small, there is no issue with copying it each time you call a worker. but i'm assuming it's intended to significantly grow over time, so that's a no-go

option 2

in theory there shouldn't be a race condition when using sharedbufferarray if array is always a valid array in the main thread as match() function takes array as-is (no additional copies) and just runs for ... of loop on it (calc…

Replies: 16 comments 11 replies

Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Answer selected by vladmandic
Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
2 replies
@uzair004
Comment options

@vladmandic
Comment options

Comment options

You must be logged in to vote
1 reply
@uzair004
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jacobg
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants