Java Code Examples for com.google.common.util.concurrent.Uninterruptibles#putUninterruptibly()

The following examples show how to use com.google.common.util.concurrent.Uninterruptibles#putUninterruptibly() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Threading.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: Threading.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: Threading.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: Threading.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: AsynchronousFileOutputStream.java    From bazel with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: Threading.java    From jelectrum with MIT License 5 votes vote down vote up
@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);
}
 
Example 7
Source File: AsynchronousFileOutputStream.java    From bazel with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}