本文整理匯總了C#中NetMQ.Msg.InitGC方法的典型用法代碼示例。如果您正苦於以下問題:C# Msg.InitGC方法的具體用法?C# Msg.InitGC怎麽用?C# Msg.InitGC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NetMQ.Msg
的用法示例。
在下文中一共展示了Msg.InitGC方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
private static void Main()
{
const int messageCount = 1000000;
const int dealerCount = 100;
Console.WriteLine("Sending {0} messages to {1} dealers", messageCount, dealerCount);
//BufferPool.SetBufferManagerBufferPool(1024 * 1024 * 10, 1024);
using (var router = new RouterSocket())
{
router.Options.SendHighWatermark = 0;
router.Bind("tcp://*:5555");
var dealers = new List<DealerSocket>();
var identities = new List<Msg>();
var random = new Random();
var identity = new byte[50];
for (var i = 0; i < dealerCount; i++)
{
random.NextBytes(identity);
var dealer = new DealerSocket
{
Options =
{
Identity = identity.Skip(10).ToArray(),
ReceiveHighWatermark = 0
}
};
dealer.Connect("tcp://localhost:5555");
dealers.Add(dealer);
var msg = new Msg();
msg.InitGC(identity, 10, identity.Length); // test offsets
identities.Add(msg);
}
Thread.Sleep(500);
while (!Console.KeyAvailable)
{
Thread.Sleep(500);
var stopwatch = Stopwatch.StartNew();
for (var i = 0; i < messageCount; i++)
{
var msg = identities[i%identities.Count];
router.Send(ref msg, true);
var msg2 = new Msg();
msg2.InitPool(1);
msg2.Put((byte) 'E');
router.Send(ref msg2, false);
}
stopwatch.Stop();
Console.WriteLine("{0:N1} messages sent per second", messageCount/stopwatch.Elapsed.TotalSeconds);
}
foreach (var dealerSocket in dealers)
dealerSocket.Dispose();
}
}