Merge branch 'poller-refactoring' into 'master'

Poller refactoring, replace Timer with ScheduledExecutorService

* Replace Timer with ScheduledExecutorService (closes #258)
* Move automatic connection logic from PluginManager to Poller
* Reschedule polling when connections are opened or closed, making the poller more responsive to reductions in the polling interval


See merge request !180
This commit is contained in:
akwizgran
2016-05-11 14:45:50 +00:00
30 changed files with 876 additions and 648 deletions

View File

@@ -2,24 +2,39 @@ package org.briarproject.api.plugins;
import org.briarproject.api.TransportId;
import org.briarproject.api.plugins.duplex.DuplexPlugin;
import org.briarproject.api.plugins.simplex.SimplexPlugin;
import java.util.Collection;
/**
* Responsible for starting transport plugins at startup, stopping them at
* shutdown, and providing access to plugins for exchanging invitations.
* Responsible for starting transport plugins at startup and stopping them at
* shutdown.
*/
public interface PluginManager {
/**
* Returns the plugin for the given transport, or null if no such plugin
* is running.
* has been created.
*/
Plugin getPlugin(TransportId t);
/** Returns any running duplex plugins that support invitations. */
/**
* Returns any simplex plugins that have been created.
*/
Collection<SimplexPlugin> getSimplexPlugins();
/**
* Returns any duplex plugins that have been created.
*/
Collection<DuplexPlugin> getDuplexPlugins();
/**
* Returns any duplex plugins that support invitations.
*/
Collection<DuplexPlugin> getInvitationPlugins();
/** Returns any running duplex plugins that support key agreement. */
/**
* Returns any duplex plugins that support key agreement.
*/
Collection<DuplexPlugin> getKeyAgreementPlugins();
}

View File

@@ -1,27 +0,0 @@
package org.briarproject.api.system;
import java.util.TimerTask;
/**
* A wrapper around a {@link java.util.Timer} that allows it to be replaced for
* testing.
*/
public interface Timer {
/** @see {@link java.util.Timer#cancel()} */
void cancel();
/** @see {@link java.util.Timer#purge()} */
int purge();
/** @see {@link java.util.Timer#schedule(TimerTask, long)} */
void schedule(TimerTask task, long delay);
/** @see {@link java.util.Timer#schedule(TimerTask, long, long)} */
void schedule(TimerTask task, long delay, long period);
/**
* @see {@link java.util.Timer#scheduleAtFixedRate(TimerTask, long, long)}
*/
void scheduleAtFixedRate(TimerTask task, long delay, long period);
}