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
using System;
using Retlang.Fibers;

namespace Retlang.Channels
{
/// <summary>
/// Channel for synchronous and asynchronous requests.
/// </summary>
/// <typeparam name="R"></typeparam>
/// <typeparam name="M"></typeparam>
public class RequestReplyChannel<R, M>: IRequestReplyChannel<R,M>
{
private readonly Channel<IRequest<R, M>> _requestChannel = new Channel<IRequest<R, M>>();

/// <summary>
/// Subscribe to requests.
/// </summary>
/// <param name="fiber"></param>
/// <param name="onRequest"></param>
/// <returns></returns>
public IDisposable Subscribe(IFiber fiber, Action<IRequest<R, M>> onRequest)
{
return _requestChannel.Subscribe(fiber, onRequest);
}

/// <summary>
/// Send request to any and all subscribers.
/// </summary>
/// <param name="p"></param>
/// <returns>null if no subscribers registered for request.</returns>
public IReply<M> SendRequest(R p)
{
var request = new ChannelRequest<R, M>(p);
return _requestChannel.Publish(request) ? request : null;
}
}
}

Change log

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
interfaces/classes
Go to: 
Project members, sign in to write a code review

Older revisions

r399 by graham.m.nash on Sep 3, 2010   Diff
Subscriptions are now disposed of when
a Fiber is disposed.
r338 by graham.m.nash on Dec 1, 2008   Diff
Deleted 2005 project.
Set all 2008 projects to use .NET
Framework 3.5.
Removed Command and in place use
Action as Java uses the native empty
...
r301 by graham.m.nash on Oct 23, 2008   Diff
Migrated to Fiber API similar to
Jetlang.
Removed old centralized bus API.
All revisions of this file

File info

Size: 1230 bytes, 37 lines

File properties

svn:mergeinfo
Powered by Google Project Hosting