本文整理汇总了C#中NetMQ.zmq.Msg.InitGC方法的典型用法代码示例。如果您正苦于以下问题:C# Msg.InitGC方法的具体用法?C# Msg.InitGC怎么用?C# Msg.InitGC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQ.zmq.Msg
的用法示例。
在下文中一共展示了Msg.InitGC方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoClient
protected override long DoClient(NetMQSocket socket, int messageSize)
{
var msg = new Msg();
msg.InitGC(new byte[messageSize], messageSize);
var watch = Stopwatch.StartNew();
for (int i = 0; i < Iterations; i++)
{
socket.Send(ref msg, SendReceiveOptions.None);
socket.Receive(ref msg, SendReceiveOptions.None);
}
return watch.ElapsedTicks;
}
示例2: Receive
public void Receive(ref Msg msg, SendReceiveOptions options)
{
LastOptions = options;
byte[] bytes = m_frames.Dequeue();
msg.InitGC(bytes, bytes.Length);
if (m_frames.Count != 0)
msg.SetFlags(MsgFlags.More);
}
示例3: Produce
protected override void Produce(PushSocket socket, int messageSize)
{
var msg = new Msg();
msg.InitGC(new byte[messageSize], messageSize);
msg.Data[messageSize/2] = 0x42;
for (int i = 0; i < MsgCount; i++)
socket.Send(ref msg, SendReceiveOptions.None);
}
示例4: Write
public void Write([NotNull] SocketBase s)
{
int size = 4 + 1 + m_addr.Length + 1; // event + len(addr) + addr + flag
if (m_flag == ValueInteger)
size += 4;
else if (m_flag == ValueChannel)
size += s_sizeOfIntPtr;
int pos = 0;
ByteArraySegment buffer = new byte[size];
buffer.PutInteger(Endianness.Little, (int)m_monitorEvent, pos);
pos += 4;
buffer[pos++] = (byte)m_addr.Length;
// was not here originally
buffer.PutString(m_addr, pos);
pos += m_addr.Length;
buffer[pos++] = ((byte)m_flag);
if (m_flag == ValueInteger)
{
buffer.PutInteger(Endianness.Little, (int)m_arg, pos);
}
else if (m_flag == ValueChannel)
{
GCHandle handle = GCHandle.Alloc(m_arg, GCHandleType.Weak);
if (s_sizeOfIntPtr == 4)
buffer.PutInteger(Endianness.Little, GCHandle.ToIntPtr(handle).ToInt32(), pos);
else
buffer.PutLong(Endianness.Little, GCHandle.ToIntPtr(handle).ToInt64(), pos);
}
var msg = new Msg();
msg.InitGC((byte[])buffer, buffer.Size);
s.Send(ref msg, 0);
}