Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/DigilibManager.java @ 290:5d0c0da080ec gen2 scaleable_1
digilib servlet version 2 ("scaleable digilib")
- first stab at using thread pools to limit resource use
- using Dug Leas util.concurrent
- doesn't mix with tomcat :-(
author | robcast |
---|---|
date | Thu, 21 Oct 2004 20:53:37 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
289:9f7b864f955f | 290:5d0c0da080ec |
---|---|
1 /* DigilibManager.java -- work queue manager | |
2 * | |
3 * Digital Image Library servlet components | |
4 * | |
5 * Copyright (C) 2004 Robert Casties (robcast@mail.berlios.de) | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify it | |
8 * under the terms of the GNU General Public License as published by the Free | |
9 * Software Foundation; either version 2 of the License, or (at your option) | |
10 * any later version. | |
11 * | |
12 * Please read license.txt for the full details. A copy of the GPL may be found | |
13 * at http://www.gnu.org/copyleft/lgpl.html | |
14 * | |
15 * You should have received a copy of the GNU General Public License along with | |
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
17 * Place, Suite 330, Boston, MA 02111-1307 USA | |
18 * | |
19 * Created on 18.10.2004 | |
20 */ | |
21 | |
22 package digilib.servlet; | |
23 | |
24 import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer; | |
25 import EDU.oswego.cs.dl.util.concurrent.Executor; | |
26 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor; | |
27 | |
28 /** work queue manager. | |
29 * | |
30 * @author casties | |
31 * | |
32 */ | |
33 public class DigilibManager implements Executor { | |
34 | |
35 private PooledExecutor workerQueue = null; | |
36 | |
37 private BoundedBuffer jobQueue = null; | |
38 | |
39 /** | |
40 * @param numFastLanes | |
41 * @param numSlowLanes | |
42 */ | |
43 public DigilibManager(int numLanes, int queueMax) { | |
44 super(); | |
45 | |
46 // create job queue | |
47 jobQueue = new BoundedBuffer(queueMax); | |
48 // create work queue | |
49 workerQueue = new PooledExecutor(jobQueue, numLanes); | |
50 workerQueue.abortWhenBlocked(); | |
51 | |
52 } | |
53 | |
54 | |
55 public void execute(Runnable worker) throws InterruptedException { | |
56 workerQueue.execute(worker); | |
57 } | |
58 | |
59 public int getQueueSize() { | |
60 return jobQueue.size(); | |
61 } | |
62 } |