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 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 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(); } } } }