This is the first part of changes to iota. Unfortunately, TermBox itself is not very thread safe.
It is possible that it is thread safe to use it as we were using it before (sort of--I could produce double free assertions pretty easily with the latest version). That is, it may be that polling events on one thread and doing all drawing on another is threadsafe. But it would require careful inspection of the code to determine, and Rust currently lacks a great way of representing that safely that will work equally well in single and multithreaded situations (that is, I don't want single threaded users to deadlock because they accidentally dropped the two components in the wrong order!) I know how to make it work nicely, but it will require &mut references to be Send, which isn't yet possible, which is why I changed iota to be single threaded for now.
In the process, this also makes the wrapper much nicer in general. It now uses RAII to properly deallocate TermBox resources, ensures that you can only ever have one RustBox handle in the program, changes panic!s to Results, uses bitflags, etc.
This is the first part of changes to iota. Unfortunately, TermBox itself is not very thread safe.
It is possible that it is thread safe to use it as we were using it before (sort of--I could produce double free assertions pretty easily with the latest version). That is, it may be that polling events on one thread and doing all drawing on another is threadsafe. But it would require careful inspection of the code to determine, and Rust currently lacks a great way of representing that safely that will work equally well in single and multithreaded situations (that is, I don't want single threaded users to deadlock because they accidentally dropped the two components in the wrong order!) I know how to make it work nicely, but it will require
&mut
references to beSend
, which isn't yet possible, which is why I changed iota to be single threaded for now.In the process, this also makes the wrapper much nicer in general. It now uses RAII to properly deallocate TermBox resources, ensures that you can only ever have one
RustBox
handle in the program, changespanic!
s toResult
s, uses bitflags, etc.