Skip to content

How to use LCell in a multithreaded context #13

Answered by uazu
jrmoulton asked this question in Q&A
Discussion options

You must be logged in to vote

What GhostCell provides (or TCell or QCell for that matter) is the ability to move the ownership from the cell itself to the 'owner' (which is called a 'token' in the GhostCell paper). So to make this work for your code, you'd need to divide the image into num_threads parts before spawning all the threads. Each part needs to have its own owner. Then one owner would be passed to each thread.

The fundamental problem with this code as it stands is that it only has one owner, and the threads can't all share the same owner mutably. In that section 1.2 it does actually say "To achieve the same for our doubly-linked list, we would use RwLock<GhostToken<'id>>." So you could do that, but that isn'…

Replies: 2 comments 1 reply

Comment options

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

Answer selected by jrmoulton
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
2 participants