AttachExistingBurden() public method

public AttachExistingBurden ( Burden burden ) : void
burden Burden
return void
Ejemplo n.º 1
0
		public virtual object Request(CreationContext context, Func<CreationContext, Burden> creationCallback)
		{
			using (rwlock.ForWriting())
			{
				if (!initialized)
				{
					Intitialize(creationCallback, context);
				}

				Burden burden;
				if (available.Count != 0)
				{
					burden = available.Pop();
					context.AttachExistingBurden(burden);
				}
				else
				{
					burden = creationCallback.Invoke(context);
				}
				try
				{
					inUse.Add(burden.Instance, burden);
				}
				catch (NullReferenceException)
				{
					throw new PoolException("creationCallback didn't return a valid burden");
				}
				catch (ArgumentNullException)
				{
					throw new PoolException("burden returned by creationCallback does not have root instance associated with it (its Instance property is null).");
				}
				return burden.Instance;
			}
		}