From: Peter S. <sz...@us...> - 2004-04-29 14:01:32
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32453/NHibernate/Cache Modified Files: CachedItem.cs Timestamper.cs Log Message: Some small H2.0.3 compatibility fix Index: CachedItem.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/CachedItem.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CachedItem.cs 17 Feb 2003 18:16:13 -0000 1.1 --- CachedItem.cs 29 Apr 2004 14:00:51 -0000 1.2 *************** *** 1,5 **** using System; ! namespace NHibernate.Cache { /// <summary> --- 1,6 ---- using System; ! namespace NHibernate.Cache ! { /// <summary> *************** *** 8,12 **** /// </summary> [Serializable] ! public class CachedItem { private long freshTimestamp; private bool fresh; --- 9,14 ---- /// </summary> [Serializable] ! public class CachedItem ! { private long freshTimestamp; private bool fresh; *************** *** 15,19 **** private object value; ! public CachedItem(object value) { this.value = value; freshTimestamp = Timestamper.Next(); --- 17,22 ---- private object value; ! public CachedItem(object value) ! { this.value = value; freshTimestamp = Timestamper.Next(); *************** *** 22,53 **** } ! public long FreshTimestamp { get { return freshTimestamp; } } ! public long UnlockTimestamp { get { return unlockTimestamp; } } ! public object Value { get { return value; } } ! public bool IsFresh { get { return fresh; } } ! public void Lock() { ! if ( 0 == theLock++ ) { fresh = false; value = null; } } ! public void Unlock() { ! if ( --theLock == 0 ) { unlockTimestamp = Timestamper.Next(); } } ! public bool IsUnlocked { get { return theLock == 0; } } --- 25,65 ---- } ! public long FreshTimestamp ! { get { return freshTimestamp; } } ! public long UnlockTimestamp ! { get { return unlockTimestamp; } } ! public object Value ! { get { return value; } } ! public bool IsFresh ! { get { return fresh; } } ! public void Lock() ! { ! if ( 0 == theLock++ ) ! { fresh = false; value = null; } } ! public void Unlock() ! { ! if ( --theLock == 0 ) ! { unlockTimestamp = Timestamper.Next(); } } ! public bool IsUnlocked ! { get { return theLock == 0; } } Index: Timestamper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/Timestamper.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Timestamper.cs 23 Apr 2003 14:42:52 -0000 1.4 --- Timestamper.cs 29 Apr 2004 14:00:51 -0000 1.5 *************** *** 2,6 **** using System.Runtime.CompilerServices; ! namespace NHibernate.Cache { /// <summary> /// Geterates increasing identifiers. --- 2,7 ---- using System.Runtime.CompilerServices; ! namespace NHibernate.Cache ! { /// <summary> /// Geterates increasing identifiers. *************** *** 10,14 **** /// strickly increasing, but usually are. /// </remarks> ! public class Timestamper { private static short counter = 0; private static long time; --- 11,16 ---- /// strickly increasing, but usually are. /// </remarks> ! public class Timestamper ! { private static short counter = 0; private static long time; *************** *** 17,30 **** [MethodImpl(MethodImplOptions.Synchronized)] ! public static long Next() { long newTime = System.DateTime.Now.Ticks << BinDigits; //is this right? ! if (time < newTime) { time = newTime; counter = 0; ! } else if (counter < OneMs - 1) { counter++; } return time + counter; } } } --- 19,40 ---- [MethodImpl(MethodImplOptions.Synchronized)] ! public static long Next() ! { long newTime = System.DateTime.Now.Ticks << BinDigits; //is this right? ! if (time < newTime) ! { time = newTime; counter = 0; ! } ! else if (counter < OneMs - 1) ! { counter++; } return time + counter; } + + private Timestamper() + { + } } } |