日期:2014-05-16 浏览次数:20865 次
unsafe class shareMemoryBase
{
internal const string shareMemoryName = "fastCSharp";
internal const int bufferSize = 1 << 20;
internal const int errorSize = int.MinValue;
protected fastCSharp.io.shareMemory shareMemory;
protected System.Threading.EventWaitHandle serverWait;
protected System.Threading.EventWaitHandle clientWait;
protected void dispose()
{
fastCSharp.pub.Dispose(ref shareMemory);
serverWait.Close();
clientWait.Close();
}
}
unsafe class server : shareMemoryBase
{
private byte[] buffer;
public unsafe server()
{
shareMemory = fastCSharp.io.shareMemory.Create(bufferSize + sizeof(int) * 6, shareMemoryName);
if (shareMemory != null)
{
fastCSharp.unsafer.memory.Fill(shareMemory.Buffer, 0U, 6);
buffer = new byte[bufferSize];
serverWait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset, shareMemory.Name + "s");
clientWait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, shareMemory.Name + "c");
&nbs