Changeset 8a001ad
- Timestamp:
- Apr 6, 2019 3:25:37 PM (2 years ago)
- Branches:
- master
- Children:
- 904bf2a
- Parents:
- 2c602fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessFilter.java
r2c602fa r8a001ad 7 7 import java.util.Iterator; 8 8 import java.util.concurrent.atomic.AtomicBoolean; 9 import java.util.concurrent.Executors; 10 import java.util.concurrent.ExecutorService; 9 11 10 12 import java.io.File; … … 42 44 private static final long SYNC_INTERVAL = 10 * 1000; 43 45 46 /** 47 * All disk i/o from all instances of this filter 48 * happen on this thread (apart from initial load) 49 */ 50 private static final ExecutorService DISK_WRITER = Executors.newSingleThreadExecutor(); 51 44 52 private final FilterDefinition definition; 45 53 private final I2PAppContext context; … … 55 63 */ 56 64 private final Map<Hash, DestTracker> unknownDests = new HashMap<Hash, DestTracker>(); 65 66 private volatile Syncer syncer; 57 67 58 68 /** … … 73 83 if (timersRunning.compareAndSet(false, true)) { 74 84 new Purger(); 75 new Syncer();85 syncer = new Syncer(); 76 86 } 77 87 } … … 80 90 public void stop() { 81 91 timersRunning.set(false); 92 syncer = null; 82 93 } 83 94 … … 201 212 if (!timersRunning.get()) 202 213 return; 203 try { 204 record(); 205 reload(); 206 schedule(SYNC_INTERVAL); 207 } catch (IOException bad) { 208 Log log = context.logManager().getLog(AccessFilter.class); 209 log.log(Log.CRIT, "syncing access list failed", bad); 210 } 211 } 214 DISK_WRITER.submit(new Runnable() { 215 @Override 216 public void run() { 217 try { 218 record(); 219 reload(); 220 Syncer syncer = AccessFilter.this.syncer; 221 if (syncer != null) 222 syncer.schedule(SYNC_INTERVAL); 223 } catch (IOException bad) { 224 Log log = context.logManager().getLog(AccessFilter.class); 225 log.log(Log.CRIT, "syncing access list failed", bad); 226 } 227 } 228 }); 229 } 212 230 } 213 231 }
Note: See TracChangeset
for help on using the changeset viewer.