2
* PROGRAM: Client/Server Common Code
4
* DESCRIPTION: Win32 Mutex support compatible with
5
* old OS versions (like Windows 95)
7
* The contents of this file are subject to the Initial
8
* Developer's Public License Version 1.0 (the "License");
9
* you may not use this file except in compliance with the
10
* License. You may obtain a copy of the License at
11
* http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
13
* Software distributed under the License is distributed AS IS,
14
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
15
* See the License for the specific language governing rights
16
* and limitations under the License.
18
* The Original Code was created by Alexander Peshkoff
19
* for the Firebird Open Source RDBMS project.
21
* Copyright (c) 2003 Alexander Peshkoff <peshkoff@mail.ru>
22
* and all contributors signed below.
24
* All Rights Reserved.
25
* Contributor(s): ______________________________________.
28
#include "../../include/firebird.h"
29
#include "../../common/classes/locks.h"
35
#define MISS_SPIN_COUNT ((tSetCriticalSectionSpinCount *)(-1))
36
#define INIT_SPIN_COUNT ((tSetCriticalSectionSpinCount *)(0))
38
tSetCriticalSectionSpinCount*
39
Spinlock::SetCriticalSectionSpinCount = INIT_SPIN_COUNT;
41
Spinlock::Spinlock() {
42
if (SetCriticalSectionSpinCount == MISS_SPIN_COUNT)
44
if (SetCriticalSectionSpinCount == INIT_SPIN_COUNT) {
45
HMODULE kernel32 = LoadLibrary("kernel32.dll");
47
SetCriticalSectionSpinCount = MISS_SPIN_COUNT;
50
SetCriticalSectionSpinCount =
51
(tSetCriticalSectionSpinCount *) GetProcAddress(
52
kernel32, "SetCriticalSectionSpinCount");
53
if (! SetCriticalSectionSpinCount) {
54
SetCriticalSectionSpinCount = MISS_SPIN_COUNT;
58
SetCriticalSectionSpinCount(&spinlock, 4000);
63
} // namespace Firebird