public class OnMainThreadJobManagerRunnerRegistry extends Object implements JobManagerRunnerRegistry, WrappingProxy<JobManagerRunnerRegistry>
OnMainThreadJobManagerRunnerRegistry
implements JobManagerRunnerRegistry
guarding
the passed JobManagerRunnerRegistry
instance in a way that it only allows modifying
methods to be executed on the component's main thread.ComponentMainThreadExecutor
Constructor and Description |
---|
OnMainThreadJobManagerRunnerRegistry(JobManagerRunnerRegistry delegate,
ComponentMainThreadExecutor mainThreadExecutor) |
Modifier and Type | Method and Description |
---|---|
JobManagerRunner |
get(JobID jobId)
Returns the
JobManagerRunner for the given JobID . |
Collection<JobManagerRunner> |
getJobManagerRunners()
Returns the registered
JobManagerRunner instances. |
Set<JobID> |
getRunningJobIds()
Returns
JobID instances of registered JobManagerRunner instances. |
JobManagerRunnerRegistry |
getWrappedDelegate()
Returns the delegated
JobManagerRunnerRegistry . |
boolean |
isRegistered(JobID jobId)
Checks whether a
JobManagerRunner is registered under the given JobID . |
CompletableFuture<Void> |
localCleanupAsync(JobID jobId,
Executor executor)
localCleanupAsync is expected to be called from the main thread. |
void |
register(JobManagerRunner jobManagerRunner)
Registers the given
JobManagerRunner instance. |
int |
size()
Returns the number of
JobManagerRunner instances currently being registered. |
JobManagerRunner |
unregister(JobID jobId)
Unregistered the
JobManagerRunner with the given JobID . |
public OnMainThreadJobManagerRunnerRegistry(JobManagerRunnerRegistry delegate, ComponentMainThreadExecutor mainThreadExecutor)
public boolean isRegistered(JobID jobId)
JobManagerRunnerRegistry
JobManagerRunner
is registered under the given JobID
.isRegistered
in interface JobManagerRunnerRegistry
jobId
- The JobID
to check.true
, if a JobManagerRunner
is registered; false
otherwise.public void register(JobManagerRunner jobManagerRunner)
JobManagerRunnerRegistry
JobManagerRunner
instance.register
in interface JobManagerRunnerRegistry
public JobManagerRunner get(JobID jobId)
JobManagerRunnerRegistry
JobManagerRunner
for the given JobID
.get
in interface JobManagerRunnerRegistry
JobManagerRunnerRegistry.isRegistered(JobID)
public int size()
JobManagerRunnerRegistry
JobManagerRunner
instances currently being registered.size
in interface JobManagerRunnerRegistry
public Set<JobID> getRunningJobIds()
JobManagerRunnerRegistry
JobID
instances of registered JobManagerRunner
instances.getRunningJobIds
in interface JobManagerRunnerRegistry
public Collection<JobManagerRunner> getJobManagerRunners()
JobManagerRunnerRegistry
JobManagerRunner
instances.getJobManagerRunners
in interface JobManagerRunnerRegistry
public CompletableFuture<Void> localCleanupAsync(JobID jobId, Executor executor)
LocallyCleanableResource
localCleanupAsync
is expected to be called from the main thread. Heavy IO tasks
should be outsourced into the passed cleanupExecutor
. Thread-safety must be ensured.localCleanupAsync
in interface LocallyCleanableResource
jobId
- The JobID
of the job for which the local data should be cleaned up.executor
- The fallback executor for IO-heavy operations.public JobManagerRunner unregister(JobID jobId)
JobManagerRunnerRegistry
JobManagerRunner
with the given JobID
. null
is
returned if there's no JobManagerRunner
registered for the given JobID
.unregister
in interface JobManagerRunnerRegistry
public JobManagerRunnerRegistry getWrappedDelegate()
JobManagerRunnerRegistry
. This method can be used to workaround
the main thread safeguard.getWrappedDelegate
in interface WrappingProxy<JobManagerRunnerRegistry>
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.