|
final CountDownLatch | latch = new CountDownLatch(1) |
|
OpLatch
is used by one thread to wait for another thread to complete (see OpLatch#waitOpComplete()
and OpLatch#waitAndAssertOpComplete()
). If the operation does not complete before the expiration time then OpLatch#waitOpComplete()
returns false
and OpLatch#waitAndAssertOpComplete()
throws an exception.
Definition at line 25 of file OpLatch.java.
◆ opComplete()
void org.dartlang.vm.service.OpLatch.opComplete |
( |
| ) |
|
|
inlinepackage |
Call to indicate that the operation completed successfully.
Definition at line 40 of file OpLatch.java.
40 {
42 }
final CountDownLatch latch
◆ opWorking()
void org.dartlang.vm.service.OpLatch.opWorking |
( |
| ) |
|
|
inline |
Set or increase the time after which the operation is considered failed. This is automatically called by waitAndAssertOp()
and waitOpComplete()
.
Definition at line 33 of file OpLatch.java.
33 {
34 endTime = System.currentTimeMillis() + 5000;
35 }
◆ waitAndAssertOpComplete()
void org.dartlang.vm.service.OpLatch.waitAndAssertOpComplete |
( |
| ) |
|
|
inlinepackage |
Wait for the operation to complete or the time limit to expire. Periodically call opWorking()
to increase the expiration time. Throw a RuntimeException
if the operation did not complete before the expiration time.
Definition at line 49 of file OpLatch.java.
49 {
51 System.out.println(">>> No response received");
52 throw new RuntimeException("No response received");
53 }
54 }
◆ waitOpComplete()
boolean org.dartlang.vm.service.OpLatch.waitOpComplete |
( |
| ) |
|
|
inlinepackage |
Wait for the operation to complete or the time limit to expire. Periodically call opWorking()
to increase the expiration time.
- Returns
true
if the operation completed, or false
otherwise
Definition at line 62 of file OpLatch.java.
62 {
64 while (true) {
65 long waitTimeMillis = endTime - System.currentTimeMillis();
66 if (waitTimeMillis <= 0) {
67 return latch.getCount() == 0;
68 }
69 try {
70 if (
latch.await(waitTimeMillis, TimeUnit.MILLISECONDS)) {
71 return true;
72 }
73 }
catch (InterruptedException
e) {
74
75 }
76 }
77 }
◆ latch
final CountDownLatch org.dartlang.vm.service.OpLatch.latch = new CountDownLatch(1) |
|
package |
The documentation for this class was generated from the following file:
- third_party/dart-lang/sdk/pkg/vm_service/java/test/org/dartlang/vm/service/OpLatch.java