Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
DummyLock | 35 | 3 | 0% | 6 | 7 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.store.locks.dummy.internal; | |
21 | ||
22 | import java.util.concurrent.TimeUnit; | |
23 | import java.util.concurrent.locks.Lock; | |
24 | import java.util.concurrent.locks.Condition; | |
25 | //import java.util.concurrent.locks.ReentrantLock; | |
26 | ||
27 | /** | |
28 | * A fake lock. | |
29 | * Used for cases when a lock is demanded by the code but the perticular operation does not require one. | |
30 | * Also useful for disabling locking. | |
31 | * | |
32 | * @version $Id: 210bf51220b510b237c2e6ec53b62f0de539a7d4 $ | |
33 | * @since 4.3M2 | |
34 | */ | |
35 | public class DummyLock implements Lock | |
36 | { | |
37 | /** a default instance, can be always used, as this {@link Lock} is stateless. */ | |
38 | public static final DummyLock INSTANCE = new DummyLock(); | |
39 | ||
40 | 24 | ![]() |
41 | public void lock() | |
42 | { | |
43 | // This is a really complicated operation. | |
44 | } | |
45 | ||
46 | 0 | ![]() |
47 | public void lockInterruptibly() | |
48 | { | |
49 | // This one even more so. | |
50 | } | |
51 | ||
52 | 0 | ![]() |
53 | public boolean tryLock() | |
54 | { | |
55 | 0 | return true; |
56 | } | |
57 | ||
58 | 0 | ![]() |
59 | public boolean tryLock(long time, TimeUnit unit) | |
60 | { | |
61 | 0 | return true; |
62 | } | |
63 | ||
64 | 24 | ![]() |
65 | public void unlock() | |
66 | { | |
67 | // Reverse of the above process. | |
68 | } | |
69 | ||
70 | 0 | ![]() |
71 | public Condition newCondition() { | |
72 | 0 | throw new UnsupportedOperationException(); |
73 | } | |
74 | } |