/// <summary> /// Creates a new instance of the <see cref="Spring.Pool.Support.SimplePool"/> /// class. /// </summary> /// <param name="factory"> /// The factory used to instantiate and manage the lifecycle of pooled objects. /// </param> /// <param name="size">The initial size of the pool.</param> /// <exception cref="System.ArgumentNullException"> /// If the supplied <paramref name="factory"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.ArgumentException"> /// If the supplied <paramref name="size"/> is less than or equal to zero. /// </exception> public SimplePool(IPoolableObjectFactory factory, int size) { AssertUtils.ArgumentNotNull(factory, "factory"); this.available = new Semaphore(size); this.factory = factory; InitItems(size); }
/// <summary> Create a channel with the given capacity and default /// semaphore implementation /// </summary> /// <exception cref="ArgumentException"> if capacity less or equal to zero /// /// </exception> public SemaphoreControlledChannel(int capacity) { if (capacity <= 0) throw new System.ArgumentException(); capacity_ = capacity; putGuard_ = new Semaphore(capacity); takeGuard_ = new Semaphore(0); }
public static string Do(int poolSize, int clientSize, int executionTime, int repeat, int creationTime) { ISync start = new Spring.Threading.Semaphore(-(clientSize - 1)); Job job = new Job(poolSize, creationTime, clientSize, start, executionTime, repeat); float elapsed = QueryPerformance.Query(job); return(String.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5:0.000} ", creationTime, executionTime, poolSize, clientSize, repeat, elapsed)); }
public static string Do(int poolSize, int clientSize, int executionTime, int repeat, int creationTime) { ISync start = new Spring.Threading.Semaphore(-(clientSize - 1)); Job job = new Job(poolSize, creationTime, clientSize, start, executionTime, repeat); float elapsed = QueryPerformance.Query(job); return String.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5:0.000} ", creationTime, executionTime, poolSize, clientSize, repeat, elapsed); }
/// <summary> Create a channel with the given capacity and /// semaphore implementations instantiated from the supplied class /// </summary> public SemaphoreControlledChannel(int capacity, System.Type semaphoreClass) { if (capacity <= 0) throw new System.ArgumentException(); capacity_ = capacity; System.Type[] longarg = new System.Type[]{System.Type.GetType("System.Int64")}; System.Reflection.ConstructorInfo ctor = semaphoreClass.GetConstructor(System.Reflection.BindingFlags.DeclaredOnly, null, longarg, null); object [] cap = new object [] {(System.Int64) capacity}; putGuard_ = (Semaphore) (ctor.Invoke(cap)); object [] zero = new object []{(System.Int64) 0}; takeGuard_ = (Semaphore) (ctor.Invoke(zero)); }