forked from zeromq/netmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stub documentation for NetMQTimer, NetMQQueue and NetMQProactor.
- Loading branch information
1 parent
c31f268
commit fd17b48
Showing
5 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters