|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
LockStrategyRepeatableRead.java | 50% | 100% | 100% | 91.7% |
|
1 | /* | |
2 | * JBoss, the OpenSource J2EE webOS | |
3 | * | |
4 | * Distributable under LGPL license. | |
5 | * See terms of license at gnu.org. | |
6 | */ | |
7 | package org.jboss.cache.lock; | |
8 | ||
9 | import java.util.concurrent.locks.Lock; | |
10 | ||
11 | /** | |
12 | * Transaction isolation level of Repeatable_Read. It prevents dirty read and non-repeatable read. | |
13 | * <p> Dirty read allows (t1) write and then (t2) read within two separate threads, all without | |
14 | * transaction commit. </p> | |
15 | * <p> Non-repeatable allows read allows (t1) read, (t2) write, and then (t1) read, all without | |
16 | * transaction commit. </p> | |
17 | * | |
18 | * @author Ben Wang | |
19 | * @version $Revision: 1.2 $ | |
20 | */ | |
21 | public class LockStrategyRepeatableRead implements LockStrategy | |
22 | { | |
23 | private ReadWriteLockWithUpgrade lock_; // Delegate is ReadWriteLockWithUpgrade | |
24 | ||
25 | 155078 | public LockStrategyRepeatableRead() |
26 | { | |
27 | 155078 | lock_ = new ReadWriteLockWithUpgrade(); |
28 | } | |
29 | ||
30 | /** | |
31 | * @see org.jboss.cache.lock.LockStrategy#readLock() | |
32 | */ | |
33 | 11949572 | public Lock readLock() |
34 | { | |
35 | 11949572 | return lock_.readLock(); |
36 | } | |
37 | ||
38 | /** | |
39 | * @see org.jboss.cache.lock.LockStrategy#upgradeLockAttempt(long) | |
40 | */ | |
41 | 11992 | public Lock upgradeLockAttempt(long msecs) throws UpgradeException |
42 | { | |
43 | 11992 | return lock_.upgradeLockAttempt(msecs); |
44 | } | |
45 | ||
46 | /** | |
47 | * @see org.jboss.cache.lock.LockStrategy#writeLock() | |
48 | */ | |
49 | 776502 | public Lock writeLock() |
50 | { | |
51 | 776502 | return lock_.writeLock(); |
52 | } | |
53 | ||
54 | ||
55 | 100 | public String toString() |
56 | { | |
57 | 100 | return lock_ != null? lock_.toString() : null; |
58 | } | |
59 | } |
|