-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveObjectOutput.cs
38 lines (34 loc) · 1.18 KB
/
ActiveObjectOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using ConcurrencyUtilities;
using System.Threading;
namespace ConcurrencyUtilities
{
/// <summary>
/// An Output Active Object is an Active Object that uses a channel to output data resulting from
/// its processing.
/// Being an abstract generic class, this is intended for use in creating a type of Output Active Object that can
/// actually do some processing and put data into its output channel.
/// </summary>
public abstract class ActiveObjectOutput<OutT>: ActiveObject
{
Channel<OutT> _output;
/// <summary>
/// Initializes a new instance of the <see cref="ConcurrencyUtilities.ActiveObjectOutput`1"/> class.
/// </summary>
/// <param name="output">The channel to use as output.</param>
public ActiveObjectOutput(Channel<OutT> output): base() {
_output = output;
}
/// <summary>
/// The Active Object's processing -- put processing result items into the output channel.
/// </summary>
protected override void Execute() {
_output.Put(Process());
}
/// <summary>
/// The Active Object's processing. Returns the result from the processing.
/// </summary>
/// <param name="item">The input item.</param>
protected abstract OutT Process();
}
}