producerCond = queueMutex.newCondition();
consumerCond = queueMutex.newCondition();
- //cpuCount = 1;
cpuCount = Runtime.getRuntime().availableProcessors();
if (cpuCount == 0) {
vlog.error("Unable to determine the number of CPU cores on this system");
bufferStream.length(), conn.cp,
entry.affectedRegion);
+ queueMutex.lock();
+
// The workers add buffers to the end so it's safe to assume
// the front is still the same buffer
freeBuffers.removeFirst();
- queueMutex.lock();
-
workQueue.addLast(entry);
// We only put a single entry on the queue so waking a single
public void run()
{
manager.queueMutex.lock();
+
while (!stopRequested) {
QueueEntry entry;
if (entry == null) {
// Wait and try again
try {
- manager.consumerCond.await();
+ manager.consumerCond.await();
} catch (InterruptedException e) { }
continue;
}
manager.queueMutex.lock();
// Remove the entry from the queue and give back the memory buffer
- manager.freeBuffers.add(entry.bufferStream);
+ manager.freeBuffers.addLast(entry.bufferStream);
manager.workQueue.remove(entry);
entry = null;
if (!manager.workQueue.peek().active)
return manager.workQueue.peek();
- for (iter = manager.workQueue.iterator(); iter.hasNext();) {
+ next:for (iter = manager.workQueue.iterator(); iter.hasNext();) {
QueueEntry entry;
Iterator<QueueEntry> iter2;
// Another thread working on this?
if (entry.active) {
lockedRegion.assign_union(entry.affectedRegion);
- continue;
+ continue next;
}
// If this is an ordered decoder then make sure this is the first
for (iter2 = manager.workQueue.iterator(); iter2.hasNext() && iter2 != iter;) {
if (entry.encoding == (iter2.next()).encoding) {
lockedRegion.assign_union(entry.affectedRegion);
- continue;
+ continue next;
}
}
}
entry2.bufferStream.length(),
entry.cp))
lockedRegion.assign_union(entry.affectedRegion);
- continue;
+ continue next;
}
}
// Check overlap with earlier rectangles
if (!lockedRegion.intersect(entry.affectedRegion).is_empty()) {
lockedRegion.assign_union(entry.affectedRegion);
- continue;
+ continue next;
}
return entry;
ImageIO.setUseCache(false);
BufferedImage jpeg =
ImageIO.read(new MemoryCacheImageInputStream(new ByteArrayInputStream(src)));
+ jpeg.setAccelerationPriority(1);
BufferedImage image = (BufferedImage)pb.getImage();
Graphics2D g2 = image.createGraphics();
g2.drawImage(jpeg, r.tl.x, r.tl.y, r.width(), r.height(), null);
g2.dispose();
- image.flush();
jpeg.flush();
} catch (IOException e) {
throw new Exception(e.getMessage());
getPreferredPF().getColorModel().createCompatibleWritableRaster(w,h));
image = new BufferedImage(getPreferredPF().getColorModel(),
getBufferRW(new Rect(0, 0, w, h)), true, null);
+ image.setAccelerationPriority(1);
}
public synchronized void fillRect(Rect r, byte[] pix)