Skip to content

Commit 40a7425

Browse files
committed
GT-3260_emteere removing lock profiling change
1 parent 4a4cb2a commit 40a7425

File tree

1 file changed

+14
-20
lines changed
  • Ghidra/Framework/Project/src/main/java/ghidra/util

1 file changed

+14
-20
lines changed
Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* ###
22
* IP: GHIDRA
3+
* REVIEWED: YES
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -16,29 +17,27 @@
1617
package ghidra.util;
1718

1819
/**
19-
* Ghidra synchronization lock. This class allows creation of named locks for
20+
* Ghidra synchronization lock. This class allows creation of named locks for
2021
* modifying tables in the Ghidra data base. This class also creates an instance
21-
* of a global lock that must first be obtained when synchronizing using
22-
* multiple of the named locks.
22+
* of a global lock that must first be obtained when synchronizing using multiple
23+
* of the named locks.
2324
*/
2425
public class Lock {
2526
private Thread owner;
2627
private int cnt = 0;
27-
private int waiting = 0;
2828
private String name;
2929

3030
/**
3131
* Creates an instance of a lock for synchronization within Ghidra.
32-
*
3332
* @param name the name of this lock
3433
*/
3534
public Lock(String name) {
3635
this.name = name;
3736
}
3837

3938
/**
40-
* Acquire this synchronization lock. (i.e. begin synchronizing on this named
41-
* lock.)
39+
* Acquire this synchronization lock.
40+
* (i.e. begin synchronizing on this named lock.)
4241
*/
4342
public synchronized void acquire() {
4443
Thread currThread = Thread.currentThread();
@@ -48,16 +47,15 @@ public synchronized void acquire() {
4847
cnt = 1;
4948
owner = currThread;
5049
return;
51-
} else if (owner == currThread) {
50+
}
51+
else if (owner == currThread) {
5252
cnt++;
5353
return;
5454
}
5555
try {
56-
waiting++;
5756
wait();
58-
} catch (InterruptedException e) {
59-
} finally {
60-
waiting--;
57+
}
58+
catch (InterruptedException e) {
6159
}
6260
}
6361
}
@@ -72,24 +70,20 @@ public synchronized void release() {
7270
if (cnt > 0 && (owner == currThread)) {
7371
if (--cnt == 0) {
7472
owner = null;
75-
// This is purely to help sample profiling. If notify() is called the
76-
// sampler can attribute time to the methods calling this erroneously. For some reason
77-
// the visualvm sampler gets a sample more often when notify() is called.
78-
if (waiting != 0) {
79-
notify();
80-
}
73+
notify();
8174
}
82-
} else {
75+
}
76+
else {
8377
throw new IllegalStateException("Attempted to release an unowned lock: " + name);
8478
}
8579
}
8680

8781
/**
8882
* Gets the thread that currently owns the lock.
89-
*
9083
* @return the thread that owns the lock or null.
9184
*/
9285
public Thread getOwner() {
9386
return owner;
9487
}
88+
9589
}

0 commit comments

Comments
 (0)