You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/AsyncFiberWorks/Core/IAsyncExecutionContext.cs
+2-2
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ public interface IAsyncExecutionContext
11
11
/// <summary>
12
12
/// Enqueue a single action. It is executed sequentially.
13
13
/// </summary>
14
-
/// <param name="func">Task generator. This is done after a pause in the fiber. The generated task is monitored and takes action to resume after completion.</param>
15
-
voidEnqueue(Func<Task<Action>>func);
14
+
/// <param name="action">Action to be executed.</param>
/// Enqueue a single action. It is executed sequentially.
207
209
/// </summary>
208
-
/// <param name="func">Task generator. This is done after a pause in the fiber. The generated task is monitored and takes action to resume after completion.</param>
209
-
publicvoidEnqueue(Func<Task<Action>>func)
210
+
/// <param name="action">Action to be executed.</param>
/// Enqueue a single action. It is executed sequentially.
176
178
/// </summary>
177
-
/// <param name="func">Task generator. This is done after a pause in the fiber. The generated task is monitored and takes action to resume after completion.</param>
178
-
publicvoidEnqueue(Func<Task<Action>>func)
179
+
/// <param name="action">Action to be executed.</param>
/// This is only called during an Execute in the fiber.
99
+
/// </summary>
100
+
/// <exception cref="InvalidOperationException">Pause was called twice.</exception>
101
+
privatevoidPause()
102
+
{
103
+
lock(_lock)
104
+
{
105
+
if(_paused)
106
+
{
107
+
thrownewInvalidOperationException("Pause was called twice.");
108
+
}
109
+
_paused=true;
110
+
if(_autoReset==null)
111
+
{
112
+
_autoReset=newAutoResetEvent(false);
113
+
}
114
+
}
115
+
}
116
+
117
+
/// <summary>
118
+
/// Resumes consumption of a paused task queue.
119
+
/// </summary>
120
+
/// <param name="action">The action to be taken immediately after the resume.</param>
121
+
/// <exception cref="InvalidOperationException">Resume was called in the unpaused state.</exception>
122
+
privatevoidResume(Actionaction)
123
+
{
124
+
lock(_lock)
125
+
{
126
+
if(!_paused)
127
+
{
128
+
thrownewInvalidOperationException("Resume was called in the unpaused state.");
129
+
}
130
+
if(_resuming)
131
+
{
132
+
thrownewInvalidOperationException("Resume was called twice.");
133
+
}
134
+
_resuming=true;
135
+
_resumeAction=action;
136
+
_autoReset.Set();
137
+
}
138
+
}
139
+
88
140
/// <summary>
89
141
/// Enqueue a single action.
90
142
/// </summary>
@@ -95,31 +147,36 @@ public void Enqueue(Action action)
95
147
}
96
148
97
149
/// <summary>
98
-
/// Enqueue a single task.
150
+
/// Enqueue a single action. It is executed sequentially.
99
151
/// </summary>
100
-
/// <param name="func">Task generator. This is done after a pause in the fiber. The generated task is monitored and takes action to resume after completion.</param>
101
-
publicvoidEnqueue(Func<Task<Action>>func)
152
+
/// <param name="action">Action to be executed.</param>
0 commit comments