Implement Models using hazard pointers #841
-
Hi. There are also a bunch of links below video, like CS papers and github to Folly (C++ library from Facebook). BR |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
The model currently must only be accessed in the GUI thread. It is neither Send not Sync. |
Beta Was this translation helpful? Give feedback.
-
@ogoffart, what do you think about pattern when I pass references to data defined in main (GUI thread by now) to some worker thread and then call invoke_from_event_loop from there which captures references again? But all updates are made in gui thread. So just some sort of universal wrapper or handle to be passed between threads but unwrapped only in event loop will do. Is it possible to have such kind of "Cell"? |
Beta Was this translation helpful? Give feedback.
-
Because SixtyFPS models are neither Send nor Sync, you'll need to duplicate data between the GUI models and your lock free backend. I am working on a realtime audio application with SixtyFPS that does this. Take a look at https://codeberg.org/Be.ing/moire/src/branch/main/src/gui.rs. In the callbacks reacting to GUI changes, I am manipulating the SixtyFPS models and sending messages over rtrb channels to manipulate the data that the realtime thread uses. The producer side of the rtrb channel from GUI to realtime thread is wrapped in |
Beta Was this translation helpful? Give feedback.
The model currently must only be accessed in the GUI thread. It is neither Send not Sync.
Hazard pointers is a way to do lock free programming, which is only making sense when working with highly concurrent data structures.
If we would want to make our code more thread friendly, we would start by using locks.
Then maybe later, as an optimization, we could try to do lockfree. But i don't think this is worth it at this point.