public unsafe bool GetAllInfo(MalockTaskInfo info) { using (MemoryStream stream = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(0); int count = 0; lock (this.malockTable) { foreach (var locker in this.malockTable.GetAllLocker()) { lock (locker) { HandleInfo handleInfo = new HandleInfo( locker.Key, locker.Identity, locker.Available); handleInfo.Serialize(stream); } count++; } } byte[] buffer = stream.GetBuffer(); fixed(byte *pinned = buffer) { *(int *)pinned = count; } MalockMessage message = this.NewMessage(info.Key, info.Identity, MalockNodeMessage.CLIENT_COMMAND_GETALLINFO, info.Sequence, -1); return(MalockMessage.TrySendMessage(info.Socket, message, buffer, 0, Convert.ToInt32(stream.Position))); } }
private void LoadAllInfo(Stream stream) { IList <HandleInfo> s = new List <HandleInfo>(); if (!HandleInfo.Fill(s, stream)) { this.socket.Abort(); return; } MalockTable malock = this.engine.GetTable(); lock (malock.GetSynchronizationObject()) { foreach (HandleInfo i in s) { if (i.Available) { malock.Exit(i.Key); } else { malock.Enter(i.Key, i.Identity); } } } }