Revision 38ac43a6 trunk/Pithos.Core/Agents/DeleteAgent.cs
b/trunk/Pithos.Core/Agents/DeleteAgent.cs | ||
---|---|---|
55 | 55 |
|
56 | 56 |
/// <summary> |
57 | 57 |
/// The Delete Agent is used to delete files from the Pithos server with high priority, |
58 |
/// blocking the network agent through the PauseEvent until all pending deletions complete
|
|
58 |
/// blocking the network agent through the ProceedEvent until all pending deletions complete
|
|
59 | 59 |
/// </summary> |
60 | 60 |
[Export] |
61 | 61 |
public class DeleteAgent |
... | ... | |
69 | 69 |
//A separate agent is used to execute delete actions immediatelly; |
70 | 70 |
private readonly ActionBlock<CloudDeleteAction> _deleteAgent; |
71 | 71 |
|
72 |
//The Pause event stops the network agent to give priority to the deletion agent |
|
72 |
//The Proceed event signals the the network agent to proceed with processing. |
|
73 |
//Essentially this event pauses the network agent to give priority to the deletion agent |
|
73 | 74 |
//Initially the event is signalled because we don't need to pause |
74 |
private readonly AsyncManualResetEvent _pauseEvent = new AsyncManualResetEvent(true);
|
|
75 |
private readonly AsyncManualResetEvent _proceedEvent = new AsyncManualResetEvent(true);
|
|
75 | 76 |
|
76 |
public AsyncManualResetEvent PauseEvent
|
|
77 |
public AsyncManualResetEvent ProceedEvent
|
|
77 | 78 |
{ |
78 |
get { return _pauseEvent; }
|
|
79 |
get { return _proceedEvent; }
|
|
79 | 80 |
} |
80 | 81 |
|
81 | 82 |
//Deleted file names are stored in memory so we can check that a file has already been deleted. |
... | ... | |
127 | 128 |
var key = GetFileKey(action.CloudFile); |
128 | 129 |
_deletedFiles[key] = DateTime.Now; |
129 | 130 |
|
130 |
_pauseEvent.Reset();
|
|
131 |
_proceedEvent.Reset();
|
|
131 | 132 |
// and then delete the file from the server |
132 | 133 |
DeleteCloudFile(accountInfo, cloudFile); |
133 | 134 |
|
... | ... | |
168 | 169 |
{ |
169 | 170 |
//Set the event when all delete actions are processed |
170 | 171 |
if (_deleteAgent.InputCount == 0) |
171 |
_pauseEvent.Set();
|
|
172 |
_proceedEvent.Set();
|
|
172 | 173 |
|
173 | 174 |
} |
174 | 175 |
} |
Also available in: Unified diff