mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Don't allow LifecycleManager to start and stop concurrently. Bug #68.
This commit is contained in:
@@ -2,8 +2,17 @@ package org.briarproject.api.lifecycle;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* Manages the lifecycle of the app, starting and stopping {@link Service
|
||||
* Services}, shutting down {@link java.util.concurrent.ExecutorService
|
||||
* ExecutorServices}, and opening and closing the {@link
|
||||
* org.briarproject.api.db.DatabaseComponent DatabaseComponent}.
|
||||
*/
|
||||
public interface LifecycleManager {
|
||||
|
||||
/** The result of calling {@link LifecycleManager#startServices()}. */
|
||||
enum StartResult { ALREADY_RUNNING, DB_ERROR, SERVICE_ERROR, SUCCESS }
|
||||
|
||||
/** Registers a {@link Service} to be started and stopped. */
|
||||
public void register(Service s);
|
||||
|
||||
@@ -14,27 +23,37 @@ public interface LifecycleManager {
|
||||
public void registerForShutdown(ExecutorService e);
|
||||
|
||||
/**
|
||||
* Starts any registered {@link Service}s and returns true if all services
|
||||
* started successfully.
|
||||
* Starts any registered {@link Service Services} and opens the {@link
|
||||
* org.briarproject.api.db.DatabaseComponent DatabaseComponent}.
|
||||
*/
|
||||
public boolean startServices();
|
||||
public StartResult startServices();
|
||||
|
||||
/**
|
||||
* Stops any registered {@link Service}s and shuts down any registered
|
||||
* {@link java.util.concurrent.ExecutorService ExecutorService}s.
|
||||
* Stops any registered {@link Service Services}, shuts down any
|
||||
* registered {@link java.util.concurrent.ExecutorService ExecutorServices},
|
||||
* and closes the {@link org.briarproject.api.db.DatabaseComponent
|
||||
* DatabaseComponent}.
|
||||
*/
|
||||
public void stopServices();
|
||||
|
||||
/** Waits for the database to be opened before returning. */
|
||||
/**
|
||||
* Waits for the {@link org.briarproject.api.db.DatabaseComponent
|
||||
* DatabaseComponent} to be opened before returning.
|
||||
*/
|
||||
public void waitForDatabase() throws InterruptedException;
|
||||
|
||||
/** Waits for all registered {@link Service}s to start before returning. */
|
||||
/**
|
||||
* Waits for the {@link org.briarproject.api.db.DatabaseComponent
|
||||
* DatabaseComponent} to be opened and all registered {@link Service
|
||||
* Services} to start before returning.
|
||||
*/
|
||||
public void waitForStartup() throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Waits for all registered {@link Service}s to stop and all registered
|
||||
* {@link java.util.concurrent.ExecutorService ExecutorService}s to shut
|
||||
* down before returning.
|
||||
* Waits for all registered {@link Service Services} to stop, all
|
||||
* registered {@link java.util.concurrent.ExecutorService ExecutorServices}
|
||||
* to shut down, and the {@link org.briarproject.api.db.DatabaseComponent
|
||||
* DatabaseComponent} to be closed before returning.
|
||||
*/
|
||||
public void waitForShutdown() throws InterruptedException;
|
||||
}
|
||||
Reference in New Issue
Block a user