D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8582 - std.parallelism unittest failure on single processor
Summary: std.parallelism unittest failure on single processor
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All Linux
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-24 12:04 UTC by edmccard
Modified: 2012-08-26 00:17 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description edmccard 2012-08-24 12:04:37 UTC
On a single-processor machine, the unittest for std.parallelism fails with the message

  Testing generated/linux/debug/64/unittest/std/parallelism
  totalCPUs = 1
  core.exception.AssertError@std.parallelism(4082): unittest failure
Comment 1 edmccard 2012-08-24 12:06:03 UTC
The problem seems to be deterministic; it happens every time (15 out of the last 15 tries) I try to run the phobos unittests, under various CPU loads.
Comment 2 David Simcha 2012-08-24 12:43:00 UTC
I'm pretty sure this is because on a single core machine the default number of threads in the TaskPool is zero.  finish() waits for all tasks to be finished by calling Thread.join().  The worker threads are supposed to finish the tasks.  If there are no worker threads there's nothing to wait on.

Instead, while the calling thread is waiting, it should pop tasks off the queue and execute them.  Furthermore, put() should throw if new tasks are placed on the queue while it's in this state.  

Will make a pull request soon.