Changeset 2c84cddd


Ignore:
Timestamp:
Apr 7, 2009 2:24:04 AM (11 years ago)
Author:
sponge <sponge@…>
Branches:
master
Children:
8c8a2de
Parents:
3766724
Message:

2009-04-07 sponge

  • SimpleTimer2, SimpleScheduler? fixed so that the threads all run from The main threadgroup, not in the current possible child threadgroup. So long as any SimpleTimer2/SimpleScheduler is started *BEFORE* any child threadgroups, the constructors are threadgroup safe. What would be super cool is if they were to be all jailed within thier very own threadgroup too, but, I2P isn't up to the task of this yet.
  • Fixes to BOB to ensure the above is true.
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • apps/BOB/src/net/i2p/BOB/BOB.java

    r3766724 r2c84cddd  
    3535import net.i2p.client.streaming.RetransmissionTimer;
    3636import net.i2p.util.Log;
     37import net.i2p.util.SimpleScheduler;
     38import net.i2p.util.SimpleTimer2;
    3739
    3840/**
     
    160162                // Re-reading the config file in each thread is pretty damn stupid.
    161163                String configLocation = System.getProperty(PROP_CONFIG_LOCATION, "bob.config");
    162 
    163164                // This is here just to ensure there is no interference with our threadgroups.
    164165                RetransmissionTimer Y = RetransmissionTimer.getInstance();
     166                SimpleScheduler Y1 = SimpleScheduler.getInstance();
     167                SimpleTimer2 Y2 = SimpleTimer2.getInstance();
    165168                i = Y.hashCode();
    166169
  • apps/BOB/src/net/i2p/BOB/Main.java

    r3766724 r2c84cddd  
    2626import net.i2p.client.streaming.RetransmissionTimer;
    2727import net.i2p.util.SimpleScheduler;
     28import net.i2p.util.SimpleTimer2;
    2829/**
    2930 * Start from command line
     
    4041                // THINK THINK THINK THINK THINK THINK
    4142                RetransmissionTimer Y = RetransmissionTimer.getInstance();
    42                 // needs SimpleScheduler
    43                 // no way to stop the scheduler?!?
    44                 SimpleScheduler.getInstance();
     43                SimpleScheduler Y1 = SimpleScheduler.getInstance();
     44                SimpleTimer2 Y2 = SimpleTimer2.getInstance();
     45
    4546                BOB.main(args);
     47
     48                Y2.stop();
     49                Y1.stop();
    4650                Y.stop();
    4751        }
  • core/java/src/net/i2p/util/SimpleScheduler.java

    r3766724 r2c84cddd  
    4343        _count = 0;
    4444        _executor = new ScheduledThreadPoolExecutor(THREADS, new CustomThreadFactory());
     45        _executor.prestartAllCoreThreads();
    4546    }
    4647   
     
    9192            Thread rv = Executors.defaultThreadFactory().newThread(r);
    9293            rv.setName(_name +  ' ' + (++_count) + '/' + THREADS);
    93             String name = rv.getThreadGroup().getName();
    94             if(!(name.isEmpty() || name.equals("Main") || name.equals("main"))) {
    95                 (new Exception("OWCH! DAMN! Wrong ThreadGroup `" + name +"', `" + rv.getName() + "'")).printStackTrace();
    96             }
     94// Uncomment this to test threadgrouping, but we should be all safe now that the constructor preallocates!
     95//            String name = rv.getThreadGroup().getName();
     96//            if(!name.equals("main")) {
     97//                (new Exception("OWCH! DAMN! Wrong ThreadGroup `" + name +"', `" + rv.getName() + "'")).printStackTrace();
     98//            }
    9799            rv.setDaemon(true);
    98100            return rv;
  • core/java/src/net/i2p/util/SimpleTimer2.java

    r3766724 r2c84cddd  
    4242        _count = 0;
    4343        _executor = new CustomScheduledThreadPoolExecutor(THREADS, new CustomThreadFactory());
     44        _executor.prestartAllCoreThreads();
    4445    }
    4546   
     
    6869            Thread rv = Executors.defaultThreadFactory().newThread(r);
    6970            rv.setName(_name + ' ' + (++_count) + '/' + THREADS);
    70             String name = rv.getThreadGroup().getName();
    71             if(!(name.isEmpty() || name.equals("Main") || name.equals("main"))) {
    72                 (new Exception("OWCH! DAMN! Wrong ThreadGroup `" + name +"', `" + rv.getName() + "'")).printStackTrace();
    73             }
     71// Uncomment this to test threadgrouping, but we should be all safe now that the constructor preallocates!
     72//            String name = rv.getThreadGroup().getName();
     73//            if(!name.equals("main")) {
     74//                (new Exception("OWCH! DAMN! Wrong ThreadGroup `" + name +"', `" + rv.getName() + "'")).printStackTrace();
     75//           }
    7476            rv.setDaemon(true);
    7577            return rv;
  • history.txt

    r3766724 r2c84cddd  
     12009-04-07 sponge
     2    * SimpleTimer2, SimpleScheduler fixed so that the threads all run from
     3      The main threadgroup, not in the current possible child threadgroup.
     4      So long as any SimpleTimer2/SimpleScheduler is started *BEFORE* any
     5      child threadgroups, the constructors are threadgroup safe. What would
     6      be super cool is if they were to be all jailed within thier very own
     7      threadgroup too, but, I2P isn't up to the task of this yet.
     8    * Fixes to BOB to ensure the above is true.
     9
    1102009-04-06 sponge
    211    * Debugging to make SimpleTimer2 and SimpleScheduler easier to debug.
  • router/java/src/net/i2p/router/RouterVersion.java

    r3766724 r2c84cddd  
    1818    public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
    1919    public final static String VERSION = CoreVersion.VERSION;
    20     public final static long BUILD = 9;
     20    public final static long BUILD = 10;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
Note: See TracChangeset for help on using the changeset viewer.