• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 2594 for trunk/components/server/src/ome/services/sessions/SessionContextImpl.java

Show
Ignore:
Timestamp:
07/05/08 22:16:05 (5 months ago)
Author:
jmoore
Message:

ticket:1018 - Changed reference counting logic

  • No longer using AtomicInteger
  • Count is not allowed to go below 0
  • Rather, SessionManager? uses sub-zero values
Files:
1 modified

  • trunk/components/server/src/ome/services/sessions/SessionContextImpl.java (modified) (3 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/server/src/ome/services/sessions/SessionContextImpl.java

    r2592 r2594  
    1111import java.util.Collections; 
    1212import java.util.List; 
    13 import java.util.concurrent.atomic.AtomicInteger; 
    1413 
    1514import ome.model.meta.Session; 
    … …  
    1716public class SessionContextImpl implements SessionContext { 
    1817 
    19     private final AtomicInteger refCount = new AtomicInteger(0); 
     18    private int ref = 0; 
     19    private final Object refLock = new Object(); 
    2020    private final Session session; 
    2121    private final List<Long> leaderOfGroups; 
    … …  
    3434 
    3535    public int refCount() { 
    36         return refCount.get(); 
     36        synchronized (refLock) { 
     37            return ref; 
     38        } 
    3739    } 
    3840 
    3941    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        } 
    4150    } 
    4251 
    4352    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        } 
    4561    } 
    4662 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/