Warning: session_start(): open(/var/lib/php/sessions/sess_o5jnrlb9l7r3p0iqg8op2pr6es, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass FastCollab is ICollab {
settable bool useMainThread = true;
volatile settable bool isDone;
int coresToUse;
FastCollabWorker[] workers;
AtomicReferenceArray workArray;
*(int coresToUse) {
this.coresToUse = max(1, coresToUse);
workArray = new AtomicReferenceArray(this.coresToUse);
}
public void addWork(Runnable work) {
if (work == null) ret;
for (int i = 0; i < workArray.length(); i++)
if (workArray.compareAndSet(i, null, work))
ret;
// Everyone is busy - do the work ourselves
work.run();
}
// returns null => sleep
// returns done => all work done
public Runnable grabWork(int workerIndex) {
if (isDone) ret DONE;
Runnable work = workArray.get(workerIndex);
if (work != null)
workArray.set(workerIndex, null);
ret work;
}
public void done { isDone(true); }
toString { ret "FastCollab*" + n2(coresToUse); }
run {
workers = new FastCollabWorker[coresToUse];
for i to coresToUse:
workers[i] = new FastCollabWorker(this, i);
for (int i = useMainThread ? 1 : 0; i < coresToUse; i++)
startThread(workers[i]);
if (useMainThread)
workers[0].run();
}
}