forked from I2P_Developers/i2p.i2p
- Thread task to open tunnel and improve UI feedback while open is pending
This commit is contained in:
@@ -250,6 +250,7 @@ public class Snark
|
||||
private String rootDataDir = ".";
|
||||
private final CompleteListener completeListener;
|
||||
private boolean stopped;
|
||||
private boolean starting;
|
||||
private byte[] id;
|
||||
private byte[] infoHash;
|
||||
private String additionalTrackerURL;
|
||||
@@ -509,9 +510,19 @@ public class Snark
|
||||
}
|
||||
|
||||
/**
|
||||
* Start up contacting peers and querying the tracker
|
||||
* Start up contacting peers and querying the tracker.
|
||||
* Blocks if tunnel is not yet open.
|
||||
*/
|
||||
public void startTorrent() {
|
||||
public synchronized void startTorrent() {
|
||||
starting = true;
|
||||
try {
|
||||
x_startTorrent();
|
||||
} finally {
|
||||
starting = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void x_startTorrent() {
|
||||
boolean ok = _util.connect();
|
||||
if (!ok) fatal("Unable to connect to I2P");
|
||||
if (coordinator == null) {
|
||||
@@ -585,7 +596,7 @@ public class Snark
|
||||
* @param fast if true, limit the life of the unannounce threads
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public void stopTorrent(boolean fast) {
|
||||
public synchronized void stopTorrent(boolean fast) {
|
||||
stopped = true;
|
||||
TrackerClient tc = trackerclient;
|
||||
if (tc != null)
|
||||
@@ -680,6 +691,22 @@ public class Snark
|
||||
return stopped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup in progress.
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public boolean isStarting() {
|
||||
return starting && stopped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set startup in progress.
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public void setStarting() {
|
||||
starting = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.8.4
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user