ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Properties | List of all members
ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection Class Reference

Public Member Functions

AsyncWrite Get (string relativePath, DateTime modifiedUtc)
 If the collection contains the specified item, it is returned. Otherwise, null is returned. More...
 
long GetQueuedBufferBytes ()
 Returns how many bytes are allocated by buffers in the queue. May be 2x the amount of data. Represents how much ram is being used by the queue, not the amount of encoded bytes that will actually be written. More...
 
void Remove (AsyncWrite w)
 Removes the specified object based on its relativepath and modifieddateutc values. More...
 
bool Queue (AsyncWrite w, WriterDelegate writerDelegate)
 Returns false when (a) the specified AsyncWrite value already exists, (b) the queue is full, or (c) the thread pool queue is full More...
 
delegate void WriterDelegate (AsyncWrite w)
 
string HashTogether (string relativePath, DateTime modifiedUtc)
 

Properties

long MaxQueueBytes [get, set]
 How many bytes of buffered file data to hold in memory before refusing futher queue requests and forcing them to be executed synchronously. More...
 

Detailed Description

Definition at line 8 of file AsyncWriteCollection.cs.

Member Function Documentation

AsyncWrite ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection.Get ( string  relativePath,
DateTime  modifiedUtc 
)
inline

If the collection contains the specified item, it is returned. Otherwise, null is returned.

Parameters
relativePath
modifiedUtc
Returns

Definition at line 33 of file AsyncWriteCollection.cs.

33  {
34  lock (_sync) {
35  AsyncWrite result;
36  return c.TryGetValue(HashTogether(relativePath, modifiedUtc), out result) ? result : null;
37  }
38  }
long ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection.GetQueuedBufferBytes ( )
inline

Returns how many bytes are allocated by buffers in the queue. May be 2x the amount of data. Represents how much ram is being used by the queue, not the amount of encoded bytes that will actually be written.

Returns

Definition at line 44 of file AsyncWriteCollection.cs.

44  {
45  lock (_sync) {
46  long total = 0;
47  foreach (AsyncWrite value in c.Values) {
48  if (value == null) continue;
49  total += value.GetBufferLength();
50  }
51  return total;
52  }
53  }
bool ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection.Queue ( AsyncWrite  w,
WriterDelegate  writerDelegate 
)
inline

Returns false when (a) the specified AsyncWrite value already exists, (b) the queue is full, or (c) the thread pool queue is full

Parameters
w
Returns

Definition at line 69 of file AsyncWriteCollection.cs.

69  {
70  lock (_sync) {
71  if (GetQueuedBufferBytes() + w.GetBufferLength() > MaxQueueBytes) return false; //Because we would use too much ram.
72  if (c.ContainsKey(HashTogether(w.RelativePath, w.ModifiedDateUtc))) return false; //We already have a queued write for this data.
73  if (!ThreadPool.QueueUserWorkItem(delegate(object state){
74  AsyncWrite job = state as AsyncWrite;
75  writerDelegate(job);
76  }, w)) return false; //thread pool refused
77  return true;
78  }
79  }
long MaxQueueBytes
How many bytes of buffered file data to hold in memory before refusing futher queue requests and forc...
long GetQueuedBufferBytes()
Returns how many bytes are allocated by buffers in the queue. May be 2x the amount of data...
void ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection.Remove ( AsyncWrite  w)
inline

Removes the specified object based on its relativepath and modifieddateutc values.

Parameters
w

Definition at line 59 of file AsyncWriteCollection.cs.

59  {
60  lock (_sync) {
61  c.Remove(HashTogether(w.RelativePath, w.ModifiedDateUtc));
62  }
63  }

Property Documentation

long ImageResizer.Plugins.DiskCache.Async.AsyncWriteCollection.MaxQueueBytes
getset

How many bytes of buffered file data to hold in memory before refusing futher queue requests and forcing them to be executed synchronously.

Definition at line 22 of file AsyncWriteCollection.cs.


The documentation for this class was generated from the following file: