Skip to content

Commit

Permalink
Add stub documentation for NetMQTimer, NetMQQueue and NetMQProactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Jan 14, 2016
1 parent c31f268 commit fd17b48
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/proactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Proactor
========

`NetMQProactor` quickly processes messages received on a socket using a dedicated thread.

:::csharp
using (var receiveSocket = new DealerSocket(">tcp://localhost:5555"))
using (var proactor = new NetMQProactor(receiveSocket,
(socket, message) => ProcessMessage(message)))
{
// ...
}

Internally the proactor creates a `NetMQPoller` for the socket, and a `NetMQActor` to coordinate
the poller thread and disposal.
22 changes: 22 additions & 0 deletions docs/queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Queue
======

`NetMQQueue<T>` is a producer-consumer queue that supports multiple producers and a single consumer.

You should add the queue to a `NetMQPoller`, and attach the consumer to its `ReceiveReady` event.
Producers call `Enqueue(T)`.

This class can eliminate boilerplate code associated with marshalling operations onto a single thread.

:::csharp
using (var queue = new NetMQQueue<ICommand>())
using (var poller = new NetMQPoller { queue })
{
queue.ReceiveReady += (sender, args) => ProcessCommand(queue.Dequeue());

poller.RunAsync();

// Then, from various threads...
queue.Enqueue(new DoSomethingCommand());
queue.Enqueue(new DoSomethingElseCommand());
}
17 changes: 17 additions & 0 deletions docs/timer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Timer
=====

A `NetMQTimer` allows actions to be performed periodically. Timer instances may be added to a `NetMQPoller`, and their
`Elapsed` event will fire according to the specified `Interval` and `Enabled` property values.

The event is raised on the poller's thread.

:::csharp
var timer = new NetMQTimer(TimeSpan.FromMilliseconds(100));

timer.Elapsed += (sender, args) => { /* handle timer event */ };

using (var poller = new NetMQPoller { timer })
{
poller.Run();
}
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pages:
- Poller: poller.md
- Actor: actor.md
- Beacon: beacon.md
- Timer: timer.md
- Queue: queue.md
- Proactor: proactor.md
- Patterns:
- Request-Response: request-response.md
- Pub-Sub: pub-sub.md
Expand Down
3 changes: 3 additions & 0 deletions src/NetMQ.sln
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{FF13931E-D
..\docs\message.md = ..\docs\message.md
..\mkdocs.yml = ..\mkdocs.yml
..\docs\poller.md = ..\docs\poller.md
..\docs\proactor.md = ..\docs\proactor.md
..\docs\pub-sub.md = ..\docs\pub-sub.md
..\docs\push-pull.md = ..\docs\push-pull.md
..\docs\queue.md = ..\docs\queue.md
..\docs\receiving-sending.md = ..\docs\receiving-sending.md
..\docs\request-response.md = ..\docs\request-response.md
..\docs\router-dealer.md = ..\docs\router-dealer.md
..\docs\scheduler.md = ..\docs\scheduler.md
..\docs\stream.md = ..\docs\stream.md
..\docs\timer.md = ..\docs\timer.md
..\docs\transports.md = ..\docs\transports.md
..\docs\xpub-xsub.md = ..\docs\xpub-xsub.md
EndProjectSection
Expand Down

0 comments on commit fd17b48

Please sign in to comment.