]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_threads.3x
ncurses 5.6 - patch 20080203
[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.4 2008/01/19 23:29:24 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_CALLBACK)(WINDOW *, void *);\fR
42 .br
43 \fBint set_escdelay(int size);\fR
44 .br
45 \fBint set_tabsize(int size);\fR
46 .br
47 \fBint use_screen(SCREEN *scr, NCURSES_CALLBACK func, void *data);\fR
48 .br
49 \fBint use_window(WINDOW *win, NCURSES_CALLBACK func, void *data);\fR
50 .br
51 .SH DESCRIPTION
52 This implementation can be configured to provide rudimentary support
53 for multi-threaded applications.
54 This makes a different set of libraries, e.g., \fIlibncursest\fP since
55 the binary interfaces are different.
56 .PP
57 Rather than modify the interfaces to pass a thread specifier to
58 each function, it adds a few functions which can be used in any
59 configuration which hide the mutex's needed to prevent concurrent
60 use of the global variables when configured for threading.
61 .PP
62 In addition to forcing access to members of the \fBWINDOW\fP structure
63 to be via functions (see \fBcurs_opaque\fP(3x)),
64 it makes functions of the common global variables,
65 e.g.,
66 COLORS,
67 COLOR_PAIRS,
68 COLS,
69 ESCDELAY,
70 LINES,
71 TABSIZE
72 curscr,
73 newscr and
74 ttytype.
75 Those variables are maintained as read-only values, stored in the \fBSCREEN\fP
76 structure.
77 .PP
78 Even this is not enough to make a thread-safe application using curses.
79 A multi-threaded application would be expected to have threads updating
80 separate windows (within the same device),
81 or updating on separate screens (on different devices).
82 Also, a few of the global variables are considered writable by some
83 applications.
84 The functions described here address these special situations.
85 .PP
86 The ESCDELAY and TABSIZE global variables are modified by some applications.
87 To modify them in any configuration,
88 use the \fBset_escdelay\fP or \fBset_tabsize\fP functions.
89 Other global variables are not modifiable.
90 .PP
91 The \fBuse_window\fP and \fBuse_screen\fP functions provide coarse
92 granularity mutexes for their respective \fBWINDOW\fP and \fBSCREEN\fP
93 parameters, and call a user-supplied function,
94 passing it a \fIdata\fP parameter,
95 and returning the value from the user-supplied function to the application.
96 .SH RETURN VALUE
97 These functions all return TRUE or FALSE, except as noted.
98 .SH NOTES
99 Both a macro and a function are provided for each name.
100 .SH PORTABILITY
101 These routines are specific to ncurses.
102 They were not supported on Version 7, BSD or System V implementations.
103 It is recommended that any code depending on ncurses extensions
104 be conditioned using NCURSES_VERSION.
105 .SH SEE ALSO
106 \fBcurses\fR(3X),
107 \fBcurs_opaque\fR(3X)
108 .\"#
109 .\"# The following sets edit modes for GNU EMACS
110 .\"# Local Variables:
111 .\"# mode:nroff
112 .\"# fill-column:79
113 .\"# End: