]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/thread.c
4 * Threading primitives for CUPS.
6 * Copyright 2009-2010 by Apple Inc.
8 * These coded instructions, statements, and computer programs are the
9 * property of Apple Inc. and are protected by Federal copyright
10 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
11 * which should have been included with this file. If this file is
12 * file is missing or damaged, see the license at "http://www.cups.org/".
16 * _cupsMutexLock() - Lock a mutex.
17 * _cupsMutexUnlock() - Unlock a mutex.
18 * _cupsThreadCreate() - Create a thread.
22 * Include necessary headers...
25 #include "cups-private.h"
26 #include "thread-private.h"
29 #if defined(HAVE_PTHREAD_H)
31 * '_cupsMutexLock()' - Lock a mutex.
35 _cupsMutexLock(_cups_mutex_t
*mutex
) /* I - Mutex */
37 pthread_mutex_lock(mutex
);
42 * '_cupsMutexUnlock()' - Unlock a mutex.
46 _cupsMutexUnlock(_cups_mutex_t
*mutex
) /* I - Mutex */
48 pthread_mutex_unlock(mutex
);
53 * '_cupsThreadCreate()' - Create a thread.
56 int /* O - 0 on failure, 1 on success */
58 _cups_thread_func_t func
, /* I - Entry point */
59 void *arg
) /* I - Entry point context */
63 return (pthread_create(&thread
, NULL
, (void *(*)(void *))func
, arg
) == 0);
72 * '_cupsMutexLock()' - Lock a mutex.
76 _cupsMutexLock(_cups_mutex_t
*mutex
) /* I - Mutex */
84 InitializeCriticalSection(&mutex
->m_criticalSection
);
91 EnterCriticalSection(&mutex
->m_criticalSection
);
96 * '_cupsMutexUnlock()' - Unlock a mutex.
100 _cupsMutexUnlock(_cups_mutex_t
*mutex
) /* I - Mutex */
102 LeaveCriticalSection(&mutex
->m_criticalSection
);
107 * '_cupsThreadCreate()' - Create a thread.
110 int /* O - 0 on failure, 1 on success */
112 _cups_thread_func_t func
, /* I - Entry point */
113 void *arg
) /* I - Entry point context */
115 return (_beginthreadex(NULL
, 0, (LPTHREAD_START_ROUTINE
) func
, arg
, 0, NULL
)
122 * '_cupsMutexLock()' - Lock a mutex.
126 _cupsMutexLock(_cups_mutex_t
*mutex
) /* I - Mutex */
132 * '_cupsMutexUnlock()' - Unlock a mutex.
136 _cupsMutexUnlock(_cups_mutex_t
*mutex
) /* I - Mutex */
139 #endif /* HAVE_PTHREAD_H */