Thread safety
sebglazebrook opened this issue · 6 comments
Hi,
I've been experimenting with rustbox and wanted to use it to across threads.
According to this commit it looks like I can: #8
But then I get this error when I try to use it in a thread:
the trait `core::marker::Send` is not implemented for the type `*mut ()`
Which I think is coming from here:
Line 221 in 7e76a04
Which indicated that termbox isn't thread safe.
Can rustbox be used in threads?
If so, any tips on how? I've tried wrapping it in Arc::new(Mutex::new(Rustbox::init())
but without luck.
Cheers
Retouching this one to show I'm still interested. :-)
+1 about this issue.
Sorry for the delay getting back to you, I was on vacation without my laptop :)
The short answer is, I'm not sure. Which I realise is not a very satisfying answer! The whole thread-safety side of things is a bit of a gray area to me at the moment unfortunately. I'll do some digging and see if I can figure it out!
I've experimented using it across threads by disabling the PhantomData (https://github.com/sebglazebrook/rustbox) and while it compiled it did hang during execution.
Haven't had a chance to investigate whether it's my code or something else.
Will let you know if I find anything.
To get back to you about the above. The issue I was seeing was due to my code.
Now that I've fixed that I've found rustbox to be fine across threads once wrapped in an Arc and Mutex.
I've created a PR (#44) to remove PhantomData unless there is another reason why it should be there.