On 02/13/2013 10:04 AM, Glenn Willen wrote:
I'd say the first thing to try -- if I'm understanding the problem right -- is 
having one task maintain the state, and having the callbacks communicate with 
that task through channels. Does that sound feasible for what you need to 
accomplish?


I don't quite understand the problem, but I agree that it is good policy to keep the world state off the thread that is doing graphics. One can start with message passing and if that's to slow maybe put the bits of mutable state that are needed for rendering into a RWARC or MutexARC.

I haven't used it personally but GLUT is notorious for it's callback-based API that doesn't provide a custom data pointer like every other sane, thread-safe, callback-based API. I believe what servo does in this situation is stuff a value into task-local storage (core::task::local_storage) immediately before the call, then pull it out after. The condition API is perfect for this (core::condition).

Interested people might want to look at or use https://github.com/mozilla-servo/rust-glut.

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to