curs_threads(3X)

NAME
use_screen, use_window - curses thread support

SYNOPSIS
#include <curses.h>

typedef int (*NCURSES_CALLBACK)(WINDOW *, void *);
int set_escdelay(int size);
int set_tabsize(int size);
int use_screen(SCREEN *scr, NCURSES_CALLBACK func, void *data);
int use_window(WINDOW *win, NCURSES_CALLBACK func, void *data);

DESCRIPTION
This implementation can be configured to provide rudimentary support for multi-threaded applications. This makes a different set of libraries, e.g., libncursest since the binary interfaces are different.

Rather than modify the interfaces to pass a thread specifier to each function, it adds a few functions which can be used in any configuration which hide the mutex's needed to prevent concurrent use of the global variables when configured for threading.

In addition to forcing access to members of the WINDOW structure to be via functions (see curs_opaque(3x)), it makes functions of the common global variables, e.g., COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES, TABSIZE curscr, newscr and ttytype. Those variables are maintained as read-only values, stored in the SCREEN structure.

Even this is not enough to make a thread-safe application using curses. A multi-threaded application would be expected to have threads updating separate windows (within the same device), or updating on separate screens (on different devices). Also, a few of the global variables are considered writable by some applications. 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.

The use_window and use_screen functions provide coarse granularity mutexes for their respective WINDOW and SCREEN parameters, and call a user-supplied function, passing it a data parameter, and returning the value from the user-supplied function to the application.

RETURN VALUE
These functions all return TRUE or FALSE, except as noted.

NOTES
Both a macro and a function are provided for each name.

PORTABILITY
These routines are specific to ncurses. They were not supported on Version 7, BSD or System V implementations. It is recommended that any code depending on ncurses extensions be conditioned using NCURSES_VERSION.

SEE ALSO
curses(3X), curs_opaque(3X)