public FixedArrayComboListEnumerator[] GetEnumerators(byte[] dlldata, string classname, string pluginsource) { ensureopen("GetEnumerators"); ensurenotenumd("GetEnumerators"); ensurewassortd("GetEnumerators"); enumd = true; FixedArrayComboListEnumerator[] results; lock (dslaves) { int i; results = new FixedArrayComboListEnumerator[dslaves.Count]; i = 0; foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; lock (slave) { bool flushed = slave.FlushAddBuf_unlocked(); if (flushed) { slave.SlaveErrorCheck(); } } results[i] = new FixedArrayComboListEnumerator(this, slave, dlldata, classname, pluginsource); results[i].buf = this.buf; // Not needed, but fine. i++; } } return(results); }
public void Add(IList <byte> key, int keyoffset, IList <byte> value, int valueoffset) { ensureopen("Add"); ensurenotenumd("Add"); ensurenotsortd("Add"); int slaveID = DetermineSlave(key, keyoffset, this.keylen); /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); bool flushed = bslave.AddBuf_unlocked(key, keyoffset, this.keylen, value, valueoffset, this.valuelen); if (flushed) { bslave.SlaveErrorCheck(); } } }
public virtual void Add(Int64 a, Int32 b) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } B12 b12; // = new B12(a, b); b12.A = a; b12.B = b; int slaveID = (int)(b12.A % dslaves.Count); /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { if (addbufinitsize > 0) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); b12.CopyToArray(buf); bslave.AddBuf_unlocked(buf, 12); } } }
void _RemoteExec(byte[] dlldata, string classname, string pluginsource) { foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; slave.nstm.WriteByte((byte)'R'); // 'R' for remoteexec if (null == classname) { XContent.SendXContent(slave.nstm, ""); } else { XContent.SendXContent(slave.nstm, classname); } XContent.SendXContent(slave.nstm, pluginsource); XContent.SendXContent(slave.nstm, dlldata); } // "Join"... foreach (SlaveInfo slave in dslaves) { slave.nstm.WriteByte((byte)'.'); // Ping. if ((int)',' != slave.nstm.ReadByte()) { throw new Exception("RemoteExec sync error (pong)"); } } }
public void SortBlocks() { ensureopen("SortBlocks"); ensurenotenumd("SortBlocks"); sortd = true; // Enter all the locks... foreach (SlaveInfo slave in dslaves) { System.Threading.Monitor.Enter(slave); // ! } try { // Sort all concurrently... foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; //if (addbufinitsize > 0) { bool flushed = slave.FlushAddBuf_unlocked(); // ! if (flushed) { slave.SlaveErrorCheck(); } } slave.nstm.WriteByte((byte)'s'); // Sort. } // Wait for acks... (join!) foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; if ((byte)'+' != slave.nstm.ReadByte()) { slave.SlaveErrorCheck(); throw new Exception("SortBlocks error: sub process " + slave.slaveID.ToString() + " did not return a valid response"); } slave.SlaveErrorCheck(); } } finally { // Release all locks... foreach (SlaveInfo slave in dslaves) { System.Threading.Monitor.Exit(slave); // ! } } }
public virtual void Flush() { if (addbufinitsize > 0) { foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; lock (slave) { slave.FlushAddBuf_unlocked(); } } } }
public virtual void Flush() { ensureopen("Flush"); ensurenotenumd("Flush"); foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; lock (slave) { bool flushed = slave.FlushAddBuf_unlocked(); if (flushed) { slave.SlaveErrorCheck(); } } } }
public virtual void Add(int a, int b) { if (!didopen) { throw new Exception("Must Open before writing to Hashtable"); } B8 b8; // = new B8(a, b); b8.A = a; b8.B = b; //b8.CopyToArray(buf); //int slaveID = DetermineSlave(buf, 8); int slaveID = ((b8.A ^ b8.B) & 0x7FFFFFFF) % dslaves.Count; /*if (slaveID < 0 || slaveID >= dslaves.Count) * { * throw new Exception("Slave missing: slaveID needed: " + slaveID.ToString()); * }*/ SlaveInfo slave = dslaves[slaveID]; lock (slave) { if (addbufinitsize > 0) { BufSlaveInfo bslave = (BufSlaveInfo)slave; bslave.EnsureAddBuf_unlocked(addbufinitsize); b8.CopyToArray(buf); bslave.AddBuf_unlocked(buf, 8); } else { // 'P' for publish/put slave.nstm.WriteByte((byte)'P'); DistObject.ToBytes(Int32.MaxValue, buf, 0); XContent.SendXContent(slave.nstm, buf, 4); b8.CopyToArray(buf); XContent.SendXContent(slave.nstm, buf, 8); // Note: no confirmation } } }
public virtual LongIntComboListEnumerator[] GetEnumerators() { if (!didopen) { throw new Exception("Attempted to GetEnumerators before Open"); } LongIntComboListEnumerator[] results; lock (dslaves) { byte enumid = nextenumid; if (nextenumid >= 32) { nextenumid = 0; } else { nextenumid++; } int i; results = new LongIntComboListEnumerator[dslaves.Count]; i = 0; foreach (SlaveInfo _slave in dslaves) { BufSlaveInfo slave = (BufSlaveInfo)_slave; if (addbufinitsize > 0) { lock (slave) { slave.FlushAddBuf_unlocked(); } } results[i] = new LongIntComboListEnumerator(slave, enumid); results[i].buf = this.buf; // Not needed, but fine. i++; } } return(results); }