Changeset 1d9b89d


Ignore:
Timestamp:
Jun 26, 2013 9:38:00 PM (7 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
c47f491
Parents:
ec70f24
Message:

volatiles, generics warning cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/JobQueue.java

    rec70f24 r1d9b89d  
    2121import java.util.concurrent.BlockingQueue;
    2222import java.util.concurrent.LinkedBlockingQueue;
     23import java.util.concurrent.atomic.AtomicInteger;
    2324
    2425import net.i2p.data.DataHelper;
     
    4142    private final Map<Integer, JobQueueRunner> _queueRunners;
    4243    /** a counter to identify a job runner */
    43     private volatile static int _runnerId = 0;
     44    private final static AtomicInteger _runnerId = new AtomicInteger(0);
    4445    /** list of jobs that are ready to run ASAP */
    4546    private final BlockingQueue<Job> _readyJobs;
     
    4849    /** job name to JobStat for that job */
    4950    private final Map<String, JobStats> _jobStats;
    50     /** how many job queue runners can go concurrently */
    51     private int _maxRunners = 1;
    5251    private final QueuePumper _pumper;
    5352    /** will we allow the # job runners to grow beyond 1? */
    54     private boolean _allowParallelOperation;
     53    private volatile boolean _allowParallelOperation;
    5554    /** have we been killed or are we alive? */
    5655    private volatile boolean _alive;
     
    142141
    143142        _alive = true;
    144         _readyJobs = new LinkedBlockingQueue();
    145         _timedJobs = new TreeSet(new JobComparator());
     143        _readyJobs = new LinkedBlockingQueue<Job>();
     144        _timedJobs = new TreeSet<Job>(new JobComparator());
    146145        _jobLock = new Object();
    147         _queueRunners = new ConcurrentHashMap(RUNNERS);
    148         _jobStats = new ConcurrentHashMap();
     146        _queueRunners = new ConcurrentHashMap<Integer,JobQueueRunner>(RUNNERS);
     147        _jobStats = new ConcurrentHashMap<String,JobStats>();
    149148        _pumper = new QueuePumper();
    150149        I2PThread pumperThread = new I2PThread(_pumper, "Job Queue Pumper", true);
     
    318317        _queueRunners.clear();
    319318        _jobStats.clear();
    320         _runnerId = 0;
     319        _runnerId.set(0);
    321320
    322321      /********
     
    441440                    JobQueueRunner runner = new JobQueueRunner(_context, i);
    442441                    _queueRunners.put(Integer.valueOf(i), runner);
    443                     Thread t = new I2PThread(runner, "JobQueue " + (++_runnerId) + '/' + numThreads, false);
     442                    Thread t = new I2PThread(runner, "JobQueue " + _runnerId.incrementAndGet() + '/' + numThreads, false);
    444443                    //t.setPriority(I2PThread.MAX_PRIORITY-1);
    445444                    t.start();
Note: See TracChangeset for help on using the changeset viewer.