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

COVERAGE SUMMARY FOR SOURCE FILE [BackportConcurrentResultQueue.java]

nameclass, %method, %block, %line, %
BackportConcurrentResultQueue.java0%   (0/1)0%   (0/6)0%   (0/37)0%   (0/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BackportConcurrentResultQueue0%   (0/1)0%   (0/6)0%   (0/37)0%   (0/12)
BackportConcurrentResultQueue (int): void 0%   (0/1)0%   (0/14)0%   (0/4)
addResult (ResultHolder): void 0%   (0/1)0%   (0/6)0%   (0/2)
aquireWait (): void 0%   (0/1)0%   (0/4)0%   (0/2)
isEmpty (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
releaseWait (): void 0%   (0/1)0%   (0/4)0%   (0/2)
takeResult (): ResultHolder 0%   (0/1)0%   (0/5)0%   (0/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 edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
20import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
21import edu.emory.mathcs.backport.java.util.concurrent.Semaphore;
22 
23/**
24 * An implementation of the {@link ResultQueue} that uses Backport Concurrent Utilities.
25 * 
26 * @author Ben Hale
27 */
28class BackportConcurrentResultQueue 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        BackportConcurrentResultQueue(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