//iterates the predicate over each page up to the page where the predicate paramenter returns true, //this method works for dependent operations that need to be executed in increasing order. //it is somewhat slower than the above as the predicate function is executed outside the task. static void IterateUntil(Func <ulong, ushort[], bool> prdct) { PrcsSpc[] ps = new PrcsSpc[NUMPRCSPCS]; for (var s = 0u; s < NUMPRCSPCS; ++s) { var buf = new ushort[BFSZ]; ps[s] = new PrcsSpc { buf = buf, tsk = cullbftsk(s * BFRNG, buf, (bfr) => { }) }; } for (var ndx = 0UL; ; ndx += BFRNG) { ps[0].tsk.Wait(); var buf = ps[0].buf; var lowi = ndx; if (prdct(lowi, buf)) { break; } for (var s = 0u; s < NUMPRCSPCS - 1; ++s) { ps[s] = ps[s + 1]; } ps[NUMPRCSPCS - 1] = new PrcsSpc { buf = buf, tsk = cullbftsk(ndx + NUMPRCSPCS * BFRNG, buf, (bfr) => { }) }; } }
//iterates the action over each page up to the page including the top_number, //making an adjustment to the top limit for the last page. //this method works for non-dependent actions that can be executed in any order. static void IterateTo(ulong top_number, Action <ulong, uint, ushort[]> actn) { PrcsSpc[] ps = new PrcsSpc[NUMPRCSPCS]; for (var s = 0u; s < NUMPRCSPCS; ++s) { ps[s] = new PrcsSpc { buf = new ushort[BFSZ], tsk = Task.Factory.StartNew(() => { }) } } ; var topndx = (top_number - FSTBP) >> 1; for (ulong ndx = 0; ndx <= topndx;) { ps[0].tsk.Wait(); var buf = ps[0].buf; for (var s = 0u; s < NUMPRCSPCS - 1; ++s) { ps[s] = ps[s + 1]; } var lowi = ndx; var nxtndx = ndx + BFRNG; var lim = topndx < nxtndx ? (uint)(topndx - ndx + 1) : BFRNG; ps[NUMPRCSPCS - 1] = new PrcsSpc { buf = buf, tsk = cullbftsk(ndx, buf, (b) => actn(lowi, lim, b)) }; ndx = nxtndx; } for (var s = 0u; s < NUMPRCSPCS; ++s) { ps[s].tsk.Wait(); } }
public nmrtr() { for (var s = 0u; s < NUMPRCSPCS; ++s) { ps[s] = new PrcsSpc { buf = new ushort[BFSZ] } } ; for (var s = 1u; s < NUMPRCSPCS; ++s) { ps[s].tsk = cullbftsk((s - 1u) * BFRNG, ps[s].buf, (bfr) => { }); } buf = ps[0].buf; } ulong _curr, i = (ulong)-WHLPTRN[WHTS - 1]; int b = -BWHLPRMS.Length - 1; uint wi = WHTS - 1; ushort v, msk = 0;