Click here to Skip to main content
15,886,060 members
Articles / High Performance Computing / Parallel Processing

Managed I/O Completion Ports (IOCP) - Part 2

Rate me:
Please Sign up or sign in to vote.
4.83/5 (31 votes)
26 Apr 200631 min read 202.9K   1.6K   127  
Lock-Free Object Pool, Lock-Free Queue, and Thread Pool for Managed IOCP.
using System;

using Sonic.Net.DataStructures.LockFree;

namespace Sonic.Net.ThreadPoolTaskFramework
{
	/// <summary>
	/// Associates a TaskHandler with a set of Tasks. It also creates
	/// a new instance of a Task that uses the associated TaskHandler
	/// </summary>
	public abstract class ContextBoundGenericTaskFactory : TaskFactory
	{
		#region Public Constructor(s)
		
		/// <summary>
		/// Default constructor
		/// </summary>
		public ContextBoundGenericTaskFactory()
		{
			// No-Op
		}

		#endregion

		#region Public Methods

		/// <summary>
		/// Creates a new Context Bound Task object .or. get an available Context Bound Task
		/// object from the object pool maintained by this instance of the
		/// Context Bound Task Factory.
		/// </summary>
		/// <param name="obj">User object that need to be associated with the new Context Bound Task instance</param>
		/// <returns>New Context Bound Task object</returns>
		public ContextBoundGenericTask NewContextBoundGenericTask(object id,object obj,IContext ctx)
		{
			ContextBoundGenericTask task = _objTaskPool.GetObject() as ContextBoundGenericTask;
			task.InitializeTask(id,obj,ctx,this);
			return task;
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
India India
Software Professional with 14+ Years of experience in design & development of server products using Microsoft Technologies.

Woked/Working on server side product development using Managed C++ & C#, including Thread pools, Asynchronous Procedure Calls (APC), Inter Process Communication (IPC) using named pipes, Lock Free data structures in C++ & .Net, etc.

Comments and Discussions