下面列出了com.google.common.util.concurrent.Uninterruptibles#putUninterruptibly ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void execute(Runnable command) {
final int size = tasks.size();
if (size == WARNING_THRESHOLD) {
log.warn(
"User thread has {} pending tasks, memory exhaustion may occur.\n" +
"If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" +
"If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" +
"Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable.", size);
}
Uninterruptibles.putUninterruptibly(tasks, command);
}
@Override
public void execute(Runnable command) {
final int size = tasks.size();
if (size == WARNING_THRESHOLD) {
log.warn(
"User thread has {} pending tasks, memory exhaustion may occur.\n" +
"If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" +
"If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" +
"Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size);
}
Uninterruptibles.putUninterruptibly(tasks, command);
}
@Override
public void execute(Runnable command) {
final int size = tasks.size();
if (size == WARNING_THRESHOLD) {
log.warn(
"User thread has {} pending tasks, memory exhaustion may occur.\n" +
"If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" +
"If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" +
"Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size);
}
Uninterruptibles.putUninterruptibly(tasks, command);
}
@Override
public void execute(Runnable command) {
if (tasks.size() > 100) {
log.warn("User thread saturated, memory exhaustion may occur.");
log.warn("Check for deadlocked or slow event handlers. Sample tasks:");
for (Object task : tasks.toArray()) log.warn(task.toString());
}
Uninterruptibles.putUninterruptibly(tasks, command);
}
/**
* Writes the byte buffer into the file asynchronously.
*
* <p>The writes are guaranteed to land in the output file in the same order that they were
* called; However, some writes may fail, leaving the file partially corrupted. In case a write
* fails, an exception will be propagated in close, but remaining writes will be allowed to
* continue.
*/
@Override
public void write(byte[] data) {
Preconditions.checkNotNull(data);
if (closeFuture.isDone()) {
if (exception.get() != null) {
// There was a write failure. Silently return without doing anything.
return;
} else {
// The file was closed.
throw new IllegalStateException();
}
}
Uninterruptibles.putUninterruptibly(queue, data);
}
@Override
public void execute(Runnable command) {
final int size = tasks.size();
if (size == WARNING_THRESHOLD) {
log.warn(
"User thread has {} pending tasks, memory exhaustion may occur.\n" +
"If you see this message, check your memory consumption and see if it's problematic or excessively spikey.\n" +
"If it is, check for deadlocked or slow event handlers. If it isn't, try adjusting the constant \n" +
"Threading.UserThread.WARNING_THRESHOLD upwards until it's a suitable level for your app, or Integer.MAX_VALUE to disable." , size);
}
Uninterruptibles.putUninterruptibly(tasks, command);
}
/**
* Returns a future that will close the stream when all pending writes are completed.
*
* Any failed writes will propagate an exception.
*/
public ListenableFuture<Void> closeAsync() {
Uninterruptibles.putUninterruptibly(queue, POISON_PILL);
return closeFuture;
}