mirror of
https://github.com/mirror/libX11.git
synced 2026-05-28 01:44:57 +08:00
Add XFreeThreads function.
This commit is contained in:
@@ -1735,6 +1735,10 @@ extern Status XInitThreads(
|
||||
void
|
||||
);
|
||||
|
||||
extern Status XFreeThreads(
|
||||
void
|
||||
);
|
||||
|
||||
extern void XLockDisplay(
|
||||
Display* /* display */
|
||||
);
|
||||
|
||||
@@ -52,6 +52,8 @@ XInitThreads, XLockDisplay, XUnlockDisplay \- multi-threading support
|
||||
.HP
|
||||
Status XInitThreads\^(void);
|
||||
.HP
|
||||
Status XFreeThreads\^(void);
|
||||
.HP
|
||||
void XLockDisplay\^(\^Display *\fIdisplay\fP\^);
|
||||
.HP
|
||||
void XUnlockDisplay\^(\^Display *\fIdisplay\fP\^);
|
||||
@@ -76,7 +78,11 @@ are protected by some other access mechanism (for example,
|
||||
a mutual exclusion lock in a toolkit or through explicit client
|
||||
programming), Xlib thread initialization is not required.
|
||||
It is recommended that single-threaded programs not call this function.
|
||||
|
||||
.LP
|
||||
The
|
||||
.B XFreeThreads
|
||||
function frees the memory allocated by
|
||||
.BR XInitThreads .
|
||||
.LP
|
||||
The
|
||||
.B XLockDisplay
|
||||
|
||||
@@ -105,4 +105,10 @@ xlib_ctor(void)
|
||||
{
|
||||
XInitThreads();
|
||||
}
|
||||
|
||||
__attribute__((destructor)) static void
|
||||
xlib_dtor(void)
|
||||
{
|
||||
XFreeThreads();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -673,9 +673,32 @@ Status XInitThreads(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Status XFreeThreads(void)
|
||||
{
|
||||
if (global_lock.lock != NULL) {
|
||||
xmutex_free(global_lock.lock);
|
||||
global_lock.lock = NULL;
|
||||
}
|
||||
if (i18n_lock.lock != NULL) {
|
||||
xmutex_free(i18n_lock.lock);
|
||||
i18n_lock.lock = NULL;
|
||||
}
|
||||
if (conv_lock.lock != NULL) {
|
||||
xmutex_free(conv_lock.lock);
|
||||
conv_lock.lock = NULL;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* XTHREADS */
|
||||
Status XInitThreads(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Status XFreeThreads(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* XTHREADS */
|
||||
|
||||
Reference in New Issue
Block a user