| Main index | Section 3 | Options |
#include <curses.h>/* data types */ typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
int get_escdelay(void); int set_escdelay(int ms); int set_tabsize(int cols);
int use_screen(SCREEN *scr, NCURSES_SCREEN_CB func, void *data); int use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data);
Instead of modifying the programming interface (API) to make ncurses functions expect an additional argument specifying a thread, the library adds functions, usable in any configuration, that hide the mutexes (mutual exclusion locks) needed to prevent concurrent access to variables shared by multiple threads of execution.
ncurses threading support requires the use of functions to access members of the WINDOW structure (see curs_opaque(3X)). It further makes functions of the common global variables COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES, TABSIZE, curscr, newscr, and ttytype, maintaining them as as read-only values in the SCREEN structure.
Even this is not enough to make an application using curses thread-safe. We would expect a multi-threaded application to have threads updating separate windows (on the same device), and separate screens (on different devices). Further, applications expect a few of the global variables to be writable. The functions described here address these special situations.
The ESCDELAY and TABSIZE global variables are modified by some applications. To modify them in any configuration, use the set_escdelay or set_tabsize functions. Other global variables are not modifiable. get_escdelay retrieves ESCDELAY's value.
The use_window and use_screen functions provide coarse-grained mutexes for their respective WINDOW and SCREEN parameters; they call a user-supplied function, pass it a data parameter, and return the value from the user-supplied function to the application.
| &#187; | global data used in the low-level terminfo or termcap interfaces |
| &#187; | terminal data associated with a call to set_curterm(3X) |
| Terminal data are initialized when screens are created. | |
| &#187; | screen data associated with a call to newterm(3X) or initscr(3X) |
| &#187; | window data associated with a call to newwin(3X) or subwin(3X) |
| Windows are associated with screens. Pads are not necessarily associated with any particular screen. | |
| Most curses applications operate on one or more windows within a single screen. | |
| &#187; | reentrant data associated with pure functions that alter no shared variables |
| 2024-03-16 | curs_threads (3X) | ncurses 6.5 |
| Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
