mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Converted plugin executor to ScheduledExecutorService.
No Thread.sleep() till Brooklyn.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package net.sf.briar.plugins;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.sf.briar.BriarTestCase;
|
||||
@@ -43,7 +43,7 @@ public class PluginManagerImplTest extends BriarTestCase {
|
||||
with(any(TransportProperties.class)));
|
||||
oneOf(poller).stopPolling();
|
||||
}});
|
||||
Executor executor = Executors.newCachedThreadPool();
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
PluginManagerImpl p = new PluginManagerImpl(executor, db, poller,
|
||||
dispatcher, uiCallback);
|
||||
// We expect either 2 or 3 plugins to be started, depending on whether
|
||||
|
||||
@@ -2,8 +2,8 @@ package net.sf.briar.plugins.bluetooth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
@@ -24,8 +24,8 @@ public class BluetoothClientTest extends StreamClientTest {
|
||||
// Create the plugin
|
||||
callback = new ClientCallback(new TransportConfig(),
|
||||
new TransportProperties(), remote);
|
||||
Executor e = Executors.newCachedThreadPool();
|
||||
plugin = new BluetoothPlugin(e, callback, 0L);
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
plugin = new BluetoothPlugin(executor, callback, 0L);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.sf.briar.plugins.bluetooth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
@@ -19,8 +19,8 @@ public class BluetoothServerTest extends StreamServerTest {
|
||||
// Create the plugin
|
||||
callback = new ServerCallback(new TransportConfig(), local,
|
||||
Collections.singletonMap(contactId, new TransportProperties()));
|
||||
Executor e = Executors.newCachedThreadPool();
|
||||
plugin = new BluetoothPlugin(e, callback, 0L);
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
plugin = new BluetoothPlugin(executor, callback, 0L);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -2,8 +2,8 @@ package net.sf.briar.plugins.socket;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
@@ -24,8 +24,8 @@ public class LanSocketClientTest extends StreamClientTest {
|
||||
// Create the plugin
|
||||
callback = new ClientCallback(new TransportConfig(),
|
||||
new TransportProperties(), remote);
|
||||
Executor e = Executors.newCachedThreadPool();
|
||||
plugin = new LanSocketPlugin(e, callback, 0L);
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
plugin = new LanSocketPlugin(executor, callback, 0L);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.sf.briar.plugins.socket;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
@@ -16,8 +16,8 @@ public class LanSocketServerTest extends StreamServerTest {
|
||||
callback = new ServerCallback(new TransportConfig(),
|
||||
new TransportProperties(),
|
||||
Collections.singletonMap(contactId, new TransportProperties()));
|
||||
Executor e = Executors.newCachedThreadPool();
|
||||
plugin = new LanSocketPlugin(e, callback, 0L);
|
||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
plugin = new LanSocketPlugin(executor, callback, 0L);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -29,8 +30,8 @@ public class SimpleSocketPluginTest extends BriarTestCase {
|
||||
StreamCallback callback = new StreamCallback();
|
||||
callback.local.put("internal", "127.0.0.1");
|
||||
callback.local.put("port", "0");
|
||||
SimpleSocketPlugin plugin = new SimpleSocketPlugin(
|
||||
Executors.newCachedThreadPool(), callback, 0L);
|
||||
ScheduledExecutorService e = Executors.newScheduledThreadPool(1);
|
||||
SimpleSocketPlugin plugin = new SimpleSocketPlugin(e, callback, 0L);
|
||||
plugin.start();
|
||||
// The plugin should have bound a socket and stored the port number
|
||||
callback.latch.await(1, TimeUnit.SECONDS);
|
||||
@@ -63,8 +64,8 @@ public class SimpleSocketPluginTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testOutgoingConnection() throws Exception {
|
||||
StreamCallback callback = new StreamCallback();
|
||||
SimpleSocketPlugin plugin = new SimpleSocketPlugin(
|
||||
Executors.newCachedThreadPool(), callback, 0L);
|
||||
ScheduledExecutorService e = Executors.newScheduledThreadPool(1);
|
||||
SimpleSocketPlugin plugin = new SimpleSocketPlugin(e, callback, 0L);
|
||||
plugin.start();
|
||||
// Listen on a local port
|
||||
final ServerSocket ss = new ServerSocket();
|
||||
|
||||
Reference in New Issue
Block a user