Pause Self, Resume on Event

dsimcha dsimcha at yahoo.com
Thu Jul 17 11:53:59 PDT 2008


Thanks.  Unfortunately, I'm using Phobos right now because Tango is not compatible
with D2, except the experimental branches, which seem *very* experimental at this
point in that I couldn't get them to compile cleanly on DMD 2.017.  I actually
wrote the thing using "yield spinning," i.e. if(var != condition) self.yield.  It
actually works reasonably well like that.  If/when Tango becomes 2.0 compatible or
Phobos gets condition mutexes, I'll probably fix this.  However, I'm so impressed
with the low latency of this thing that, for my purposes (futures and other
similar ways of exploiting very fine-grained parallelism), it might be better this
way.  I ran some microbenchmarks to find the break even job size for running jobs
in serial w/o thread pool overhead vs. running them in parallel on the thread
pool.  If the benchmarks are accurate, on my 2-core rig it's only about 3
microseconds/job.  This assumes you're queueing up a large number of jobs and then
waiting for all of them to finish.

On another note, anyone have any idea when/if Tango for D2, and Tangobos for Tango
for D2, will be available?  There are things I like and dislike about both Tango
and Phobos, and I really wish I could mix and match modules from them without
giving up my D2 features.  For example, I like Phobos's much simpler IO API, less
"OO everywhere" look and feel and "simple operations should be simple" mentality,
but I like Tango's extra math and threading stuff and richer feature set in
general.  Also, I've written a decent amount of Phobos code that I don't feel like
porting.


More information about the Digitalmars-d-learn mailing list