Skip to content

Commit ebd01c6

Browse files
committed
rename from ThreadJob to InvokeJob to ease readability
1 parent 85ef98c commit ebd01c6

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/DebuggerController.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public final class DebuggerController implements ContextsListener {
7575
private final Map<Object, SimpleLock> suspendLocks = Collections.synchronizedMap(new HashMap<>());
7676
private final Map<Object, SuspendedInfo> suspendedInfos = Collections.synchronizedMap(new HashMap<>());
7777
private final Map<Object, SteppingInfo> commandRequestIds = new HashMap<>();
78-
private final Map<Object, ThreadJob<?>> threadJobs = new HashMap<>();
78+
private final Map<Object, InvokeJob<?>> invokeJobs = new HashMap<>();
7979
private final Map<Object, FieldBreakpointEvent> fieldBreakpointExpected = new HashMap<>();
8080
private final Map<Object, MethodBreakpointEvent> methodBreakpointExpected = new HashMap<>();
8181
private final Map<Breakpoint, BreakpointInfo> breakpointInfos = new HashMap<>();
@@ -698,9 +698,9 @@ private void lockThread(Object thread, boolean forceSuspend, List<Callable<Void>
698698
// we have the actual suspension status and suspended information
699699
threadSuspension.removeHardSuspendedThread(thread);
700700
fine(() -> "lock.wait() for thread: " + getThreadName(thread));
701-
// Having the thread lock, we can check if a thread job was posted outside of
701+
// Having the thread lock, we can check if an invoke job was posted outside of
702702
// locking, and if so, we postpone blocking the thread until next time around.
703-
if (!threadJobs.containsKey(thread)) {
703+
if (!invokeJobs.containsKey(thread)) {
704704
lock.wait();
705705
}
706706
}
@@ -709,22 +709,22 @@ private void lockThread(Object thread, boolean forceSuspend, List<Callable<Void>
709709
// make sure the interrupted flag is set though
710710
Thread.currentThread().interrupt();
711711
}
712-
checkThreadJobsAndRun(thread);
712+
checkInvokeJobsAndRun(thread);
713713
}
714714
fine(() -> "lock wakeup for thread: " + getThreadName(thread));
715715
}
716716

717-
private void checkThreadJobsAndRun(Object thread) {
718-
if (threadJobs.containsKey(thread)) {
719-
ThreadJob<?> job = threadJobs.remove(thread);
717+
private void checkInvokeJobsAndRun(Object thread) {
718+
if (invokeJobs.containsKey(thread)) {
719+
InvokeJob<?> job = invokeJobs.remove(thread);
720720
job.runJob(this);
721721
}
722722
}
723723

724-
public void postJobForThread(ThreadJob<?> job) {
724+
public void postInvokeJobForThread(InvokeJob<?> job) {
725725
SimpleLock lock = getSuspendLock(job.getThread());
726726
synchronized (lock) {
727-
threadJobs.put(job.getThread(), job);
727+
invokeJobs.put(job.getThread(), job);
728728
lock.notifyAll();
729729
}
730730
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import java.util.concurrent.Callable;
2626

27-
public final class ThreadJob<T> {
27+
public final class InvokeJob<T> {
2828

2929
private final Object jobLock = new Object();
3030
private final Object thread;
@@ -33,11 +33,11 @@ public final class ThreadJob<T> {
3333
private boolean resultAvailable;
3434
private JobResult<T> result;
3535

36-
public ThreadJob(Object guestThread, Callable<T> task) {
36+
public InvokeJob(Object guestThread, Callable<T> task) {
3737
this(guestThread, task, SuspendStrategy.EVENT_THREAD);
3838
}
3939

40-
public ThreadJob(Object guestThread, Callable<T> task, byte suspensionStrategy) {
40+
public InvokeJob(Object guestThread, Callable<T> task, byte suspensionStrategy) {
4141
this.thread = guestThread;
4242
this.callable = task;
4343
this.suspensionStrategy = suspensionStrategy;

espresso/src/com.oracle.truffle.espresso.jdwp/src/com/oracle/truffle/espresso/jdwp/impl/JDWP.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
11631163
try {
11641164
// we have to call the method in the correct thread, so post a
11651165
// Callable to the controller and wait for the result to appear
1166-
ThreadJob<Object> job = new ThreadJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy);
1167-
controller.postJobForThread(job);
1166+
InvokeJob<Object> job = new InvokeJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy);
1167+
controller.postInvokeJobForThread(job);
11681168

11691169
// invocation of a method can cause events with possible thread suspension
11701170
// to happen, e.g. class prepare events for newly loaded classes
@@ -1175,8 +1175,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
11751175
public void run() {
11761176
CommandResult commandResult = new CommandResult(reply);
11771177
try {
1178-
ThreadJob<?>.JobResult<?> result = job.getResult();
1179-
writeMethodResult(reply, context, result, thread, controller);
1178+
InvokeJob<?>.JobResult<?> result = job.getResult();
1179+
writeMethodResult(reply, context, result);
11801180
} catch (Throwable t) {
11811181
reply.errorCode(ErrorCodes.INTERNAL);
11821182
controller.severe(INVOKE_METHOD.class.getName() + ".createReply", t);
@@ -1246,15 +1246,15 @@ static CommandResult createReply(Packet packet, DebuggerController controller) {
12461246
try {
12471247
// we have to call the constructor in the correct thread, so post a
12481248
// Callable to the controller and wait for the result to appear
1249-
ThreadJob<?> job = new ThreadJob<>(thread, () -> {
1249+
InvokeJob<?> job = new InvokeJob<>(thread, () -> {
12501250
args[0] = context.allocateInstance(klass);
12511251
method.invokeMethodSpecial(args);
12521252
return args[0];
12531253
}, suspensionStrategy);
1254-
controller.postJobForThread(job);
1255-
ThreadJob<?>.JobResult<?> result = job.getResult();
1254+
controller.postInvokeJobForThread(job);
1255+
InvokeJob<?>.JobResult<?> result = job.getResult();
12561256

1257-
writeMethodResult(reply, context, result, thread, controller);
1257+
writeMethodResult(reply, context, result);
12581258
} catch (Throwable t) {
12591259
throw new RuntimeException("not able to invoke static method through jdwp", t);
12601260
}
@@ -1350,8 +1350,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
13501350
try {
13511351
// we have to call the method in the correct thread, so post a
13521352
// Callable to the controller and wait for the result to appear
1353-
ThreadJob<Object> job = new ThreadJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy);
1354-
controller.postJobForThread(job);
1353+
InvokeJob<Object> job = new InvokeJob<>(thread, () -> method.invokeMethodStatic(args), suspensionStrategy);
1354+
controller.postInvokeJobForThread(job);
13551355
// invocation of a method can cause events with possible thread suspension
13561356
// to happen, e.g. class prepare events for newly loaded classes
13571357
// to avoid blocking here, we fire up a new thread that will post
@@ -1361,8 +1361,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
13611361
public void run() {
13621362
CommandResult commandResult = new CommandResult(reply);
13631363
try {
1364-
ThreadJob<?>.JobResult<?> result = job.getResult();
1365-
writeMethodResult(reply, context, result, thread, controller);
1364+
InvokeJob<?>.JobResult<?> result = job.getResult();
1365+
writeMethodResult(reply, context, result);
13661366
} catch (Throwable t) {
13671367
reply.errorCode(ErrorCodes.INTERNAL);
13681368
controller.severe(INVOKE_METHOD.class.getName() + "." + "createReply", t);
@@ -1807,7 +1807,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
18071807
try {
18081808
// we have to call the method in the correct thread, so post a
18091809
// Callable to the controller and wait for the result to appear
1810-
ThreadJob<Object> job = new ThreadJob<>(thread, () -> {
1810+
InvokeJob<Object> job = new InvokeJob<>(thread, () -> {
18111811
if (invokeNonvirtual) {
18121812
return method.invokeMethodNonVirtual(args);
18131813
} else if (Modifier.isPrivate(method.getModifiers())) {
@@ -1818,7 +1818,7 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
18181818
return method.invokeMethodVirtual(args);
18191819
}
18201820
}, suspensionStrategy);
1821-
controller.postJobForThread(job);
1821+
controller.postInvokeJobForThread(job);
18221822
// invocation of a method can cause events with possible thread suspension
18231823
// to happen, e.g. class prepare events for newly loaded classes
18241824
// to avoid blocking here, we fire up a new thread that will post
@@ -1828,8 +1828,8 @@ static CommandResult createReply(Packet packet, DebuggerController controller, D
18281828
public void run() {
18291829
CommandResult commandResult = new CommandResult(reply);
18301830
try {
1831-
ThreadJob<?>.JobResult<?> result = job.getResult();
1832-
writeMethodResult(reply, context, result, thread, controller);
1831+
InvokeJob<?>.JobResult<?> result = job.getResult();
1832+
writeMethodResult(reply, context, result);
18331833
} catch (Throwable t) {
18341834
reply.errorCode(ErrorCodes.INTERNAL);
18351835
controller.severe(INVOKE_METHOD.class.getName() + "." + "createReply", t);
@@ -2393,11 +2393,11 @@ static CommandResult createReply(Packet packet, DebuggerController controller) {
23932393
}
23942394

23952395
// make sure owned monitors taken in frame are exited
2396-
ThreadJob<Void> job = new ThreadJob<>(thread, () -> {
2396+
InvokeJob<Void> job = new InvokeJob<>(thread, () -> {
23972397
controller.getContext().clearFrameMonitors(topFrame);
23982398
return null;
23992399
});
2400-
controller.postJobForThread(job);
2400+
controller.postInvokeJobForThread(job);
24012401
// don't return here before job completed
24022402
job.getResult();
24032403

@@ -3042,7 +3042,7 @@ public static void writeValue(byte tag, Object value, PacketStream reply, boolea
30423042
}
30433043
}
30443044

3045-
private static void writeMethodResult(PacketStream reply, JDWPContext context, ThreadJob<?>.JobResult<?> result, Object thread, DebuggerController controller) {
3045+
private static void writeMethodResult(PacketStream reply, JDWPContext context, InvokeJob<?>.JobResult<?> result) {
30463046
if (result.getException() != null) {
30473047
reply.writeByte(TagConstants.OBJECT);
30483048
reply.writeLong(0);

0 commit comments

Comments
 (0)