EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.repeat.support]

COVERAGE SUMMARY FOR SOURCE FILE [JdkConcurrentResultQueue.java]

nameclass, %method, %block, %line, %
JdkConcurrentResultQueue.java100% (1/1)100% (6/6)100% (37/37)100% (12/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JdkConcurrentResultQueue100% (1/1)100% (6/6)100% (37/37)100% (12/12)
JdkConcurrentResultQueue (int): void 100% (1/1)100% (14/14)100% (4/4)
addResult (ResultHolder): void 100% (1/1)100% (6/6)100% (2/2)
aquireWait (): void 100% (1/1)100% (4/4)100% (2/2)
isEmpty (): boolean 100% (1/1)100% (4/4)100% (1/1)
releaseWait (): void 100% (1/1)100% (4/4)100% (2/2)
takeResult (): ResultHolder 100% (1/1)100% (5/5)100% (1/1)

1/*
2 * Copyright 2002-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.repeat.support;
18 
19import java.util.concurrent.BlockingQueue;
20import java.util.concurrent.LinkedBlockingQueue;
21import java.util.concurrent.Semaphore;
22 
23/**
24 * An implementation of the {@link ResultQueue} that uses the Java 5 Concurrent Utilities.
25 * 
26 * @author Ben Hale
27 */
28class JdkConcurrentResultQueue extends AbstractResultQueue implements RepeatInternalState {
29 
30        // Accumulation of result objects as they finish.
31        private final BlockingQueue results;
32 
33        // Accumulation of dummy objects flagging expected results in the future.
34        private final Semaphore waits;
35 
36        JdkConcurrentResultQueue(int throttleLimit) {
37                results = new LinkedBlockingQueue();
38                waits = new Semaphore(throttleLimit);
39        }
40 
41        protected void addResult(ResultHolder resultHolder) {
42                results.add(resultHolder);
43        }
44 
45        protected void aquireWait() throws InterruptedException {
46                waits.acquire();
47        }
48 
49        protected void releaseWait() {
50                waits.release();
51        }
52 
53        protected ResultHolder takeResult() throws InterruptedException {
54                return (ResultHolder) results.take();
55        }
56 
57        public boolean isEmpty() {
58                return results.isEmpty();
59        }
60 
61}

[all classes][org.springframework.batch.repeat.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov