Class AsyncHandle

java.lang.Object
com.oracle.libuv.Handle
com.oracle.libuv.AsyncHandle
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class AsyncHandle
extends Handle
Async handles allow the user to wakeup the event loop and get a callback called from another thread.

See Async handle

  • Field Summary

    Fields inherited from class com.oracle.libuv.Handle

    loop, pointer
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the handle and free up any resources that may be held by it.
    int send()
    Wake up the event loop and call the specified callback.
    void setAsyncCallback​(AsyncCallback callback)
    Attach a AsyncCallback.

    Methods inherited from class com.oracle.libuv.Handle

    equals, hashCode, isClosing, ref, toString, unref

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • setAsyncCallback

      public void setAsyncCallback​(AsyncCallback callback)
      Attach a AsyncCallback.
      Parameters:
      callback - A callback, which will be executed after a loop will receive an async signal from this handle.
      Throws:
      java.lang.IllegalStateException - if this method called more than once.
    • send

      public int send()
      Wake up the event loop and call the specified callback.

      It's safe to call this function from any thread. The callback will be called on the loop thread.

      Returns:
      0 on success, or an error code < 0 on failure.
    • close

      public void close()
      Close the handle and free up any resources that may be held by it.

      CloseCallback callback will be invoked right before the close.