- Timestamp:
- 07/05/08 22:16:05 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/server/src/ome/services/sessions/SessionContextImpl.java
r2592 r2594 11 11 import java.util.Collections; 12 12 import java.util.List; 13 import java.util.concurrent.atomic.AtomicInteger;14 13 15 14 import ome.model.meta.Session; … … 17 16 public class SessionContextImpl implements SessionContext { 18 17 19 private final AtomicInteger refCount = new AtomicInteger(0); 18 private int ref = 0; 19 private final Object refLock = new Object(); 20 20 private final Session session; 21 21 private final List<Long> leaderOfGroups; … … 34 34 35 35 public int refCount() { 36 return refCount.get(); 36 synchronized (refLock) { 37 return ref; 38 } 37 39 } 38 40 39 41 public int increment() { 40 return refCount.incrementAndGet(); 42 synchronized (refLock) { 43 if (ref < 0) { 44 ref = 1; 45 } else { 46 ref = ref + 1; 47 } 48 return ref; 49 } 41 50 } 42 51 43 52 public int decrement() { 44 return refCount.decrementAndGet(); 53 synchronized (refLock) { 54 if (ref < 1) { 55 ref = 0; 56 } else { 57 ref = ref - 1; 58 } 59 return ref; 60 } 45 61 } 46 62
