![]() |
Statistics for MySQL
0.9
|
00001 /* sqlthread.h (Threading) */ 00002 00003 /*********************************************************************** 00004 * This code is part of Statistics for MySQL. 00005 * 00006 * Copyright (C) 2011 Heinrich Schuchardt (xypron.glpk@gmx.de) 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 ***********************************************************************/ 00020 00026 #ifndef SQLTHREAD_H 00027 00028 #define SQLTHREAD_H 1 00029 00030 #ifdef HAVE_CONF_H 00031 #include "config.h" 00032 #endif // HAVE_CONF_H 00033 00034 void sqlsleep(long msecs); 00035 #ifdef SQLWIN 00036 #include <windows.h> 00037 typedef CRITICAL_SECTION pthread_mutex_t; 00038 typedef DWORD pthread_t; 00039 //@todo The return type of routine C is "DWORD" for Windows and "void *" for Posix. 00040 //@todo The handle returned by CreateThread should be released with CloseHandle. 00041 #define pthread_create(A,B,C,D) (int)(CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&C,D,0,A)==NULL) 00042 #define pthread_exit(A) ExitThread(0) 00043 #define pthread_mutex_destroy(A) DeleteCriticalSection(A) 00044 #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0) 00045 #define pthread_mutex_lock(A) (EnterCriticalSection(A),0) 00046 #define pthread_mutex_unlock(A) (LeaveCriticalSection(A),0) 00047 #define pthread_self() GetCurrentThreadId() 00048 #else 00049 #include <pthread.h> 00050 #endif 00051 00052 #endif // SQLTHREAD_H