public class BackgroundRequestCoordinator extends Object
ThreadFactory and the
JavaRuntime code that processes the fake request.
Background threads are backed by a "fake" request, which is
initiated using the System API. The System API will return a
request identifier and also initiate a "fake" request with this
identifier stored in a header. The runtime must match each fake
request up with the original API call and pass the user's
Runnable to the thread so it can be executed, and pass the
Thread back to the user's code so it can be joined and
referenced.
Unfortunately there is a race between these two threads. We don't know whether the System API RPC will return first or whether the background request will be received first.
| Constructor and Description |
|---|
BackgroundRequestCoordinator() |
| Modifier and Type | Method and Description |
|---|---|
Thread |
waitForThreadStart(String requestId,
Runnable runnable,
long deadlineInMillis)
Wait for the fake request with the specified
requestId to
call waitForUserRunnable(java.lang.String, java.lang.Thread, long) and then exchange
runnable for the specified Thread. |
Runnable |
waitForUserRunnable(String requestId,
Thread thread,
long deadLineInMillis)
Wait for the system API call with the specified
requestId
to call waitForThreadStart(java.lang.String, java.lang.Runnable, long) and then exchange
thread for the specified Runnable. |
public Thread waitForThreadStart(String requestId, Runnable runnable, long deadlineInMillis) throws InterruptedException, TimeoutException
requestId to
call waitForUserRunnable(java.lang.String, java.lang.Thread, long) and then exchange
runnable for the specified Thread.InterruptedExceptionTimeoutExceptionpublic Runnable waitForUserRunnable(String requestId, Thread thread, long deadLineInMillis) throws InterruptedException, TimeoutException
requestId
to call waitForThreadStart(java.lang.String, java.lang.Runnable, long) and then exchange
thread for the specified Runnable.InterruptedExceptionTimeoutExceptionCopyright © 2022. All rights reserved.