3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/****************************************************************************
26
Basic Locks for Threads
30
**************************************************************************/
31
#include "P_EventSystem.h"
33
ClassAllocator<ProxyMutex> mutexAllocator("mutexAllocator");
35
// #define ERROR_CONFIG_TAG_LOCKS
37
#ifdef ERROR_CONFIG_TAG_LOCKS
41
#ifdef DEBUG // debug build needs lock_* functions
46
lock_waiting(const char *file, int line, const char *handler)
51
#ifdef ERROR_CONFIG_TAG_LOCKS
52
if (is_diags_on("locks"))
53
fprintf(stderr, "WARNING: waiting on lock %s:%d for %s\n",
54
file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
59
lock_holding(const char *file, int line, const char *handler)
64
#ifdef ERROR_CONFIG_TAG_LOCKS
65
if (is_diags_on("locks"))
66
fprintf(stderr, "WARNING: holding lock %s:%d too long for %s\n",
67
file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
72
lock_taken(const char *file, int line, const char *handler)
77
#ifdef ERROR_CONFIG_TAG_LOCKS
78
if (is_diags_on("locks"))
79
fprintf(stderr, "WARNING: lock %s:%d taken too many times for %s\n",
80
file ? file : "UNKNOWN", line, handler ? handler : "UNKNOWN");
84
#ifdef LOCK_CONTENTION_PROFILING
86
ProxyMutex::print_lock_stats(int flag)
89
if (total_acquires < 10)
91
printf("Lock Stats (Dying):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n",
92
successful_nonblocking_acquires,
93
(nonblocking_acquires > 0 ?
94
successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0),
95
unsuccessful_nonblocking_acquires,
96
(nonblocking_acquires > 0 ?
97
unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires);
100
if (!(total_acquires % 100)) {
101
printf("Lock Stats (Alive):successful %d (%.2f%%), unsuccessful %d (%.2f%%) blocking %d \n",
102
successful_nonblocking_acquires,
103
(nonblocking_acquires > 0 ?
104
successful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0),
105
unsuccessful_nonblocking_acquires,
106
(nonblocking_acquires > 0 ?
107
unsuccessful_nonblocking_acquires * 100.0 / nonblocking_acquires : 0.0), blocking_acquires);
112
#endif //LOCK_CONTENTION_PROFILING