Package org.kobe.xbot.JClient
Class XTablesClientManager
java.lang.Object
org.kobe.xbot.JClient.XTablesClientManager
XTablesClientManager - Manages the asynchronous startup and retrieval of an XTablesClient instance.
This class ensures that the client starts in a separate thread and provides methods to check its readiness. It supports non-blocking retrieval, blocking retrieval, and retrieval with a timeout.
Author: Kobe Lei Version: 1.0 Package: org.kobe.xbot.JClient
This is part of the XTABLES project and provides controlled access to the XTablesClient.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBlocks until the client is initialized and returns it.getAndBlock
(long timeout, TimeUnit unit) Blocks for a specified duration until the client is initialized and returns it.Retrieves the client if it is ready, otherwise returns null.boolean
Checks whether the client has been successfully initialized.
-
Constructor Details
-
XTablesClientManager
public XTablesClientManager()
-
-
Method Details
-
isClientReady
public boolean isClientReady()Checks whether the client has been successfully initialized.- Returns:
- true if the client is ready, false otherwise.
-
getOrNull
Retrieves the client if it is ready, otherwise returns null.- Returns:
- the initialized XTablesClient or null if not yet ready.
-
getAndBlock
Blocks until the client is initialized and returns it.- Returns:
- the initialized XTablesClient.
- Throws:
InterruptedException
- if the waiting thread is interrupted.ExecutionException
- if the initialization fails.
-
getAndBlock
public XTablesClient getAndBlock(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Blocks for a specified duration until the client is initialized and returns it.- Parameters:
timeout
- the maximum time to wait.unit
- the time unit of the timeout argument.- Returns:
- the initialized XTablesClient.
- Throws:
InterruptedException
- if the waiting thread is interrupted.ExecutionException
- if the initialization fails.TimeoutException
- if the timeout expires before the client is ready.
-