Exemplo n.º 1
0
 /// <summary>
 /// Removes the specified object based on its relativepath and modifieddateutc values.
 /// </summary>
 /// <param name="w"></param>
 public void Remove(AsyncWrite w)
 {
     lock (_sync)
     {
         c.Remove(w.Path);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns false when (a) the specified AsyncWrite value already exists, (b) the queue is full, or (c) the thread pool queue is full
 /// </summary>
 /// <param name="w"></param>
 /// <returns></returns>
 public bool Queue(AsyncWrite w, WriterDelegate writerDelegate)
 {
     lock (_sync)
     {
         if (GetQueuedBufferBytes() + w.GetBufferLength() > MaxQueueBytes)
         {
             return(false);                                                              //Because we would use too much ram.
         }
         if (c.ContainsKey(w.Path))
         {
             return(false);                       //We already have a queued write for this data.
         }
         if (!ThreadPool.QueueUserWorkItem(delegate(object state) {
             AsyncWrite job = state as AsyncWrite;
             writerDelegate(job);
         }, w))
         {
             return(false);   //thread pool refused
         }
         return(true);
     }
 }