Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
sqlthread.h
Go to the documentation of this file.
1 /* sqlthread.h (Threading) */
2 
3 /***********************************************************************
4 * This code is part of Statistics for MySQL.
5 *
6 * Copyright (C) 2011 Heinrich Schuchardt (xypron.glpk@gmx.de)
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 ***********************************************************************/
20 
26 #ifndef SQLTHREAD_H
27 
28 #define SQLTHREAD_H 1
29 
30 #ifdef HAVE_CONF_H
31 #include "config.h"
32 #endif // HAVE_CONF_H
33 
34 void sqlsleep(long msecs);
35 #ifdef SQLWIN
36 #include <windows.h>
37 typedef CRITICAL_SECTION pthread_mutex_t;
38 typedef DWORD pthread_t;
39 //@todo The return type of routine C is "DWORD" for Windows and "void *" for Posix.
40 //@todo The handle returned by CreateThread should be released with CloseHandle.
41 #define pthread_create(A,B,C,D) (int)(CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)&C,D,0,A)==NULL)
42 #define pthread_exit(A) ExitThread(0)
43 #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
44 #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
45 #define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
46 #define pthread_mutex_unlock(A) (LeaveCriticalSection(A),0)
47 #define pthread_self() GetCurrentThreadId()
48 #else
49 #include <pthread.h>
50 #endif
51 
52 #endif // SQLTHREAD_H
void sqlsleep(long msecs)
Let thread sleep.
Definition: sqlthread.c:39