internal bool Add(InternalTransaction tx) { int index = Interlocked.Increment(ref this.index); if (index < this.size) { tx.tableBucket = this; tx.bucketIndex = index; Thread.MemoryBarrier(); this.transactions[index] = tx; if (!this.timedOut) { goto Label_0097; } lock (tx) { tx.State.Timeout(tx); goto Label_0097; } } Bucket bucket = new Bucket(this.owningSet) { nextBucketWeak = new WeakReference(this) }; if (Interlocked.CompareExchange<Bucket>(ref this.owningSet.headBucket, bucket, this) == this) { this.previous = bucket; } return false; Label_0097: return true; }
internal bool Add(InternalTransaction tx) { int currentIndex = Interlocked.Increment(ref _index); if (currentIndex < _size) { tx._tableBucket = this; tx._bucketIndex = currentIndex; Interlocked.MemoryBarrier(); // This data must be written before the transaction // could be timed out. _transactions[currentIndex] = tx; if (_timedOut) { lock (tx) { tx.State.Timeout(tx); } } } else { Bucket newBucket = new Bucket(_owningSet); newBucket.nextBucketWeak = new WeakReference(this); Bucket oldBucket = Interlocked.CompareExchange(ref _owningSet.headBucket, newBucket, this); if (oldBucket == this) { // ladies and gentlemen we have a winner. _previous = newBucket; } return false; } return true; }
internal void TimeoutTransactions() { Bucket headBucket = this.headBucket; do { headBucket.TimeoutTransactions(); WeakReference nextBucketWeak = headBucket.nextBucketWeak; if (nextBucketWeak != null) { headBucket = (Bucket) nextBucketWeak.Target; } else { headBucket = null; } } while (headBucket != null); }
internal BucketSet( TransactionTable table, long absoluteTimeout ) { this.headBucket = new Bucket( this ); this.table = table; this.absoluteTimeout = absoluteTimeout; }
internal BucketSet(TransactionTable table, long absoluteTimeout) { headBucket = new Bucket(this); _table = table; _absoluteTimeout = absoluteTimeout; }