Exemplo n.º 1
0
 /// <summary>
 /// Gets spotter from pool. If no spotter is available and capacity is reached exeption is raised.
 /// </summary>
 /// <param name="contentType">Content type defining wanted spotter.</param>
 /// <returns></returns>
 public SpotterBase GetSpotter(string contentType)
 {
     lock (this._lock)
     {
         if (this.IsFreeOf(SpotterFactory.GetSpotterType(contentType)))
         {
             return(this.GetFreeSpotter(contentType));
         }
         else
         {
             return(this.CreateNextSpotter(contentType));
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns spotter from pool or waits if no free spotter is available.
 /// </summary>
 /// <param name="contentType">Content type defining wanted spotter.</param>
 /// <returns></returns>
 public SpotterBase GetSpotterOrWait(string contentType)
 {
     lock (this._lock)
     {
         if (this.IsFreeOf(SpotterFactory.GetSpotterType(contentType)))
         {
             // Free instances exists
             return(this.GetFreeSpotter(contentType));
         }
         else if (this._total < this._capacity || this._capacity == 0)
         {
             // No free instances but free capacity
             return(this.CreateNextSpotter(contentType));
         }
         else
         {
             do
             {
                 Monitor.Wait(this._lock);
             } while(this.IsFreeOf(SpotterFactory.GetSpotterType(contentType)));
             return(this.GetFreeSpotter(contentType));
         }
     }
 }