Commit 1596ea72 authored by Jeremy Huddleston's avatar Jeremy Huddleston

XQuartz: Use a lighter spinlock instead of a pthread_mutex_t in QuartzScreenSaver

Currently, we only end up here through a call to QuartzShowFullscreen, and
this is always on the same thread.  Future changes (such as further
incorporating libdispatch) may allow this to change, but contention will
remain minimal since the call is infrequent and it is short held.
Signed-off-by: default avatarJeremy Huddleston <>
Reviewed-by: default avatarDaniel A. Steffen <>
parent 3e253c60
......@@ -62,7 +62,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <pthread.h>
#include <libkern/OSAtomic.h>
#include <signal.h>
#include <rootlessCommon.h>
......@@ -279,10 +279,10 @@ static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) {
static void QuartzScreenSaver(int state) {
static CFRunLoopTimerRef pokeActivityTimer = NULL;
static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
static pthread_mutex_t pokeActivityMutex = PTHREAD_MUTEX_INITIALIZER;
static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
if(state) {
if(pokeActivityTimer == NULL)
goto QuartzScreenSaverEnd;
......@@ -303,7 +303,7 @@ static void QuartzScreenSaver(int state) {
CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
void QuartzShowFullscreen(int state) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment