My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using Retlang.Fibers;

namespace Retlang.Channels
{
/// <summary>
/// Channel subscription methods.
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ISubscriber<T>
{
///<summary>
/// Subscribe to messages on this channel. The provided action will be invoked via a Action on the provided executor.
///</summary>
///<param name="fiber">the target executor to receive the message</param>
///<param name="receive"></param>
///<returns>Unsubscriber object</returns>
IDisposable Subscribe(IFiber fiber, Action<T> receive);

/// <summary>
/// Subscribes to actions on the channel in batch form. The events will be batched if the consumer is unable to process the events
/// faster than the arrival rate.
/// </summary>
/// <param name="fiber">The target context to execute the action</param>
/// <param name="receive"></param>
/// <param name="intervalInMs">Time in Ms to batch actions. If 0 events will be delivered as fast as consumer can process</param>
/// <returns></returns>
IDisposable SubscribeToBatch(IFiber fiber, Action<IList<T>> receive, long intervalInMs);

///<summary>
/// Batches actions based upon keyed values allowing for duplicates to be dropped.
///</summary>
///<param name="fiber"></param>
///<param name="keyResolver"></param>
///<param name="receive"></param>
///<param name="intervalInMs"></param>
///<typeparam name="K"></typeparam>
///<returns></returns>
IDisposable SubscribeToKeyedBatch<K>(IFiber fiber, Converter<T, K> keyResolver, Action<IDictionary<K, T>> receive, long intervalInMs);

/// <summary>
/// Subscription that delivers the latest message to the consuming thread. If a newer message arrives before the consuming thread
/// has a chance to process the message, the pending message is replaced by the newer message. The old message is discarded.
/// </summary>
/// <param name="fiber"></param>
/// <param name="receive"></param>
/// <param name="intervalInMs"></param>
/// <returns></returns>
IDisposable SubscribeToLast(IFiber fiber, Action<T> receive, long intervalInMs);

/// <summary>
/// Removes all subscribers.
/// </summary>
void ClearSubscribers();
}
}

Change log

r427 by graham.m.nash on Mar 30, 2011   Diff
Fixed intervals having unmarked time units
or being ints later converted to longs
Go to: 
Project members, sign in to write a code review

Older revisions

r401 by graham.m.nash on Sep 3, 2010   Diff
Added BusyWaitQueue
Extracted DefaultQueue from
BoundedQueue and made DefaultQueue
default in ThreadFiber
Various renames/removals of redundant
...
r399 by graham.m.nash on Sep 3, 2010   Diff
Subscriptions are now disposed of when
a Fiber is disposed.
r374 by graham.m.nash on Nov 6, 2009   Diff
Added documentation to new
SnapshotChannel.
Incremented version number.
All revisions of this file

File info

Size: 2565 bytes, 57 lines
Powered by Google Project Hosting