ThreadManager
An interface that controls the thread pools and thread factories used by the Admin SDK. Each
instance of FirebaseApp uses an implementation of this interface to create and manage
threads.
Multiple app instances may use the same ThreadManager instance.
Methods in this interface may get invoked multiple times by the same
app, during its lifetime. Apps may also invoke methods of this interface concurrently and
so implementations should provide any synchronization necessary.
Public Constructor Summary
Protected Method Summary
| abstract ExecutorService | |
| abstract ThreadFactory |
Returns the |
| abstract void |
Inherited Method Summary
From class java.lang.Object
| Object |
clone() |
| boolean |
equals(Object arg0) |
| void |
finalize() |
| final Class<?> |
getClass() |
| int |
hashCode() |
| final void |
notify() |
| final void |
notifyAll() |
| String |
toString() |
| final void |
wait(long arg0, int arg1) |
| final void |
wait(long arg0) |
| final void |
wait() |
Public Constructors
public ThreadManager ()
Protected Methods
protected abstract ExecutorService getExecutor (FirebaseApp app)
Returns the main thread pool for an app. Implementations may return the same instance of
ExecutorService for multiple apps. The returned thread pool is used for
short-lived tasks by all components of an app.
For long-lived tasks (such as the ones started by the Realtime Database client), the SDK
creates dedicated executors using the ThreadFactory returned by the
getThreadFactory() method.
Returns
- A non-null
ExecutorServiceinstance.
protected abstract ThreadFactory getThreadFactory ()
Returns the ThreadFactory to be used for creating long-lived threads. This is
used mainly to create the long-lived worker threads for the Realtime Database client, and
other scheduled (periodic) tasks started by the SDK. The SDK guarantees
clean termination of all threads started via this ThreadFactory, when the user
calls delete().
If long-lived threads cannot be supported in the current runtime, this method may
throw a RuntimeException.
Returns
- A non-null
ThreadFactory.
protected abstract void releaseExecutor (FirebaseApp app, ExecutorService executor)
Cleans up the thread pool associated with an app. This method is invoked when an app
is deleted. This is guaranteed to be called with the ExecutorService previously
returned by getExecutor(FirebaseApp) for the corresponding app.