Class AsyncHandle

java.lang.Object
com.oracle.libuv.Handle
com.oracle.libuv.AsyncHandle
All Implemented Interfaces:
Closeable, 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

  • 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:
      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.