EMMA Coverage Report (generated Thu Jan 20 11:39:44 EST 2011)
[all classes][com.hammurapi.common.concurrent]

COVERAGE SUMMARY FOR SOURCE FILE [CountedRunnable.java]

nameclass, %method, %block, %line, %
CountedRunnable.java0%   (0/2)0%   (0/6)0%   (0/53)0%   (0/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CountedRunnable0%   (0/1)0%   (0/2)0%   (0/25)0%   (0/10)
CountedRunnable (CountedRunnable$Counter, Runnable): void 0%   (0/1)0%   (0/11)0%   (0/5)
run (): void 0%   (0/1)0%   (0/14)0%   (0/5)
     
class CountedRunnable$Counter0%   (0/1)0%   (0/4)0%   (0/28)0%   (0/9)
CountedRunnable$Counter (): void 0%   (0/1)0%   (0/3)0%   (0/1)
dec (): void 0%   (0/1)0%   (0/11)0%   (0/3)
inc (): void 0%   (0/1)0%   (0/7)0%   (0/2)
join (): void 0%   (0/1)0%   (0/7)0%   (0/3)

1package com.hammurapi.common.concurrent;
2 
3 
4/**
5 * This class increments counter when created and 
6 * decrements when run() method exits. When counter reaches zero, this
7 * class invokes notifyAll() on the counter. The class shall be used for 
8 * parallel execution of tasks when it is required to wait until all tasks
9 * complete.
10 * @author Pavel Vlasov
11 *
12 */
13public class CountedRunnable implements Runnable {
14        
15        /**
16         * Counter to use with CounterRunnable.
17         * @author Pavel Vlasov
18         */
19        public static class Counter {
20                private int counter;
21                
22                synchronized void inc() {
23                        ++counter;
24                }
25                
26                synchronized void dec() {
27                        if (--counter <= 0) {
28                                notifyAll();
29                        }
30                }
31                
32                public synchronized void join() throws InterruptedException {
33                        while (counter>0) {
34                                wait();
35                        }
36                }
37        }
38        
39        private Counter counter;
40        private Runnable master;
41 
42        public CountedRunnable(Counter counter, Runnable master) {
43                this.counter = counter;
44                counter.inc();
45                this.master = master;
46        }
47 
48        final public void run() {
49                try {
50                        master.run();
51                } finally {
52                        counter.dec();
53                }
54        }
55 
56}

[all classes][com.hammurapi.common.concurrent]
EMMA 2.0.5312 EclEmma Fix 2 (C) Vladimir Roubtsov