ncurses appears popular library. 1 of weaknesses is, not threadsafe. should not hard wrap shared ressources in mutexes.
is there specific reason, why noone has started threadsafe branch? (legal issues, introducing platform dependency, ...)
edit: not mean use_screen or use_window functions. these apparently require user change ncurses-based code. should possible add mutex shared resources within ncurses itself, , accessing functions acquire mutex before doing window. imagining within ncurses:
#if __cplusplus >= 201103l #include <mutex> #define threadsafe #endif ... #ifdef threadsafe std::recursive_mutex mxcurscr; #endif ... int doupdate(void) { #ifdef threadsafe mxcurscr.lock(); #endif ... // <-- access screen here. #ifdef threadsafe mxcurscr.unlock() #endif }
- this not rely on c++11 standard.
- this compatible older compilers. (but no threadsafety then.)
- it should not take more 1 or 2 days make modifications.
- this satisfies demand threadsafe ncurses.
- the user of ncurses library not have bother.
- the work being done 1 time users, instead of having every user implementing own thread-safety.
so, catch?
it's been done (in ncurses 5.7, released november 2008), not used. see curs_threads
manual page instance. not feature in default configuration because it
- changes abi (application binary interface), and
- adds restrictions on how standard variables used.