]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_threads.3x
ae588c4c0290a9a6be36e9054ded31a9b842985d
[ncurses.git] / man / curs_threads.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2008 Free Software Foundation, Inc.                        *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_threads.3x,v 1.5 2008/03/29 20:28:12 tom Exp $
30 .TH curs_threads 3X ""
31 .na
32 .hy 0
33 .SH NAME
34 \fBuse_screen\fR,
35 \fBuse_window\fR - \fBcurses\fR thread support
36 .ad
37 .hy
38 .SH SYNOPSIS
39 \fB#include <curses.h>\fR
40 .sp
41 \fBtypedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);\fR
42 \fBtypedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);\fR
43 .br
44 \fBint set_escdelay(int size);\fR
45 .br
46 \fBint set_tabsize(int size);\fR
47 .br
48 \fBint use_screen(SCREEN *scr, NCURSES_WINDOW_CB func, void *data);\fR
49 .br
50 \fBint use_window(WINDOW *win, NCURSES_SCREEN_CB func, void *data);\fR
51 .br
52 .SH DESCRIPTION
53 This implementation can be configured to provide rudimentary support
54 for multi-threaded applications.
55 This makes a different set of libraries, e.g., \fIlibncursest\fP since
56 the binary interfaces are different.
57 .PP
58 Rather than modify the interfaces to pass a thread specifier to
59 each function, it adds a few functions which can be used in any
60 configuration which hide the mutex's needed to prevent concurrent
61 use of the global variables when configured for threading.
62 .PP
63 In addition to forcing access to members of the \fBWINDOW\fP structure
64 to be via functions (see \fBcurs_opaque\fP(3x)),
65 it makes functions of the common global variables,
66 e.g.,
67 COLORS,
68 COLOR_PAIRS,
69 COLS,
70 ESCDELAY,
71 LINES,
72 TABSIZE
73 curscr,
74 newscr and
75 ttytype.
76 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
77 structure.
78 .PP
79 Even this is not enough to make a thread-safe application using curses.
80 A multi-threaded application would be expected to have threads updating
81 separate windows (within the same device),
82 or updating on separate screens (on different devices).
83 Also, a few of the global variables are considered writable by some
84 applications.
85 The functions described here address these special situations.
86 .PP
87 The ESCDELAY and TABSIZE global variables are modified by some applications.
88 To modify them in any configuration,
89 use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
90 Other global variables are not modifiable.
91 .PP
92 The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
93 granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
94 parameters, and call a user-supplied function,
95 passing it a \fIdata\fP parameter,
96 and returning the value from the user-supplied function to the application.
97 .SH RETURN VALUE
98 These functions all return TRUE or FALSE, except as noted.
99 .SH NOTES
100 Both a macro and a function are provided for each name.
101 .SH PORTABILITY
102 These routines are specific to ncurses.
103 They were not supported on Version 7, BSD or System V implementations.
104 It is recommended that any code depending on ncurses extensions
105 be conditioned using NCURSES_VERSION.
106 .SH SEE ALSO
107 \fBcurses\fR(3X),
108 \fBcurs_opaque\fR(3X)
109 .\"#
110 .\"# The following sets edit modes for GNU EMACS
111 .\"# Local Variables:
112 .\"# mode:nroff
113 .\"# fill-column:79
114 .\"# End: