-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add BspEvent and LockEvent #7
Conversation
this.lock.lock(); | ||
try { | ||
while (!this.signaled) { | ||
time = deadline - System.currentTimeMillis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deal with time<0
|
||
public class LockEvent implements BspEvent { | ||
|
||
private Lock lock = new ReentrantLock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set final
} | ||
|
||
@Override | ||
public boolean waitMillis(long time) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to wait without timeout
|
||
@Override | ||
public void waitOrFail(long time) { | ||
E.checkArgument(time >= 0L, "The time must be >= 0, but got %d.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap line
} | ||
} | ||
} catch (InterruptedException e) { | ||
throw new ComputerException( "Interrupted while waiting %d. ", e, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style:
remove unused " " and "."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also improve message: "Interrupted while waiting 10" is confusing
long deadline = System.currentTimeMillis() + time; | ||
while (!this.waitMillis(time)) { | ||
if (System.currentTimeMillis() > deadline) { | ||
throw new ComputerException("Timeout waiting, time = '%d'.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve message: wait for what?
boolean waitMillis(long time); | ||
|
||
/** | ||
* Wait specified time in millisecond, for throw ComputerException if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for -> or
} | ||
|
||
@Override | ||
public void signal() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signalAll
@Test | ||
public void testWaitOrFail() { | ||
LockEvent lockEvent = new LockEvent(); | ||
Assert.assertThrows(ComputerException.class, () -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try e to assert e.getMessage()
commit to hugegraph-common apache/incubator-hugegraph-commons#60 |
* add HugeInputSplitFetcher#client timeout * skip edge when fail to convert
No description provided.