Server.FileQueue.Commit C# (CSharp) Méthode

Commit() private méthode

private Commit ( Chunk chunk, int slot ) : void
chunk Chunk
slot int
Résultat void
		private void Commit( Chunk chunk, int slot ) {
			if ( slot < 0 || slot >= active.Length ) {
				throw new ArgumentOutOfRangeException( "slot" );
			}

			lock ( syncRoot ) {
				if ( active[slot] != chunk ) {
					throw new ArgumentException();
				}

				bufferPool.ReleaseBuffer( chunk.Buffer );

				if ( pending.Count > 0 ) {
					Page page = pending.Dequeue();

					active[slot] = new Chunk( this, slot, page.buffer, 0, page.length );

					callback( active[slot] );
				} else {
					active[slot] = null;
				}

				--activeCount;

				if ( activeCount == 0 ) {
					idle.Set();
				}
			}
		}

Usage Example

		private void FileCallback( FileQueue.Chunk chunk ) {
			if ( FileOperations.AreSynchronous ) {
				fileStream.Write( chunk.Buffer, chunk.Offset, chunk.Size );

				if ( metrics != null ) {
					metrics.OnFileWritten( chunk.Size );
				}

				chunk.Commit();
			} else {
				if ( writeCallback == null ) {
					writeCallback = this.OnWrite;
				}

				fileStream.BeginWrite( chunk.Buffer, chunk.Offset, chunk.Size, writeCallback, chunk );
			}
		}
All Usage Examples Of Server.FileQueue::Commit