"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/isc/win32/include/isc/thread.h" (4 Sep 2020, 2333 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "thread.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef ISC_THREAD_H
   13 #define ISC_THREAD_H 1
   14 
   15 #include <windows.h>
   16 
   17 #include <isc/lang.h>
   18 #include <isc/result.h>
   19 
   20 /*
   21  * Inlines to help with wait return checking
   22  */
   23 
   24 /* check handle for NULL and INVALID_HANDLE */
   25 inline BOOL
   26 IsValidHandle(HANDLE hHandle) {
   27     return ((hHandle != NULL) && (hHandle != INVALID_HANDLE_VALUE));
   28 }
   29 
   30 /* validate wait return codes... */
   31 inline BOOL
   32 WaitSucceeded(DWORD dwWaitResult, DWORD dwHandleCount) {
   33     return ((dwWaitResult >= WAIT_OBJECT_0) &&
   34         (dwWaitResult < WAIT_OBJECT_0 + dwHandleCount));
   35 }
   36 
   37 inline BOOL
   38 WaitAbandoned(DWORD dwWaitResult, DWORD dwHandleCount) {
   39     return ((dwWaitResult >= WAIT_ABANDONED_0) &&
   40         (dwWaitResult < WAIT_ABANDONED_0 + dwHandleCount));
   41 }
   42 
   43 inline BOOL
   44 WaitTimeout(DWORD dwWaitResult) {
   45     return (dwWaitResult == WAIT_TIMEOUT);
   46 }
   47 
   48 inline BOOL
   49 WaitFailed(DWORD dwWaitResult) {
   50     return (dwWaitResult == WAIT_FAILED);
   51 }
   52 
   53 /* compute object indices for waits... */
   54 inline DWORD
   55 WaitSucceededIndex(DWORD dwWaitResult) {
   56     return (dwWaitResult - WAIT_OBJECT_0);
   57 }
   58 
   59 inline DWORD
   60 WaitAbandonedIndex(DWORD dwWaitResult) {
   61     return (dwWaitResult - WAIT_ABANDONED_0);
   62 }
   63 
   64 typedef HANDLE isc_thread_t;
   65 typedef DWORD  isc_threadresult_t;
   66 typedef void * isc_threadarg_t;
   67 typedef isc_threadresult_t(WINAPI *isc_threadfunc_t)(isc_threadarg_t);
   68 
   69 #define isc_thread_self (unsigned long)GetCurrentThreadId
   70 
   71 ISC_LANG_BEGINDECLS
   72 
   73 void
   74 isc_thread_create(isc_threadfunc_t, isc_threadarg_t, isc_thread_t *);
   75 
   76 void
   77 isc_thread_join(isc_thread_t, isc_threadresult_t *);
   78 
   79 void
   80 isc_thread_setconcurrency(unsigned int level);
   81 
   82 void
   83 isc_thread_setname(isc_thread_t, const char *);
   84 
   85 isc_result_t
   86 isc_thread_setaffinity(int cpu);
   87 
   88 #define isc_thread_yield() Sleep(0)
   89 
   90 #if HAVE___DECLSPEC_THREAD
   91 #define ISC_THREAD_LOCAL static __declspec(thread)
   92 #else /* if HAVE___DECLSPEC_THREAD */
   93 #error "Thread-local storage support is required!"
   94 #endif /* if HAVE___DECLSPEC_THREAD */
   95 
   96 ISC_LANG_ENDDECLS
   97 
   98 #endif /* ISC_THREAD_H */