[m-rev.] for review: Add barriers (for concurrency) to the standard library
Peter Wang
novalazy at gmail.com
Wed Apr 23 16:34:59 AEST 2014
On Wed, 23 Apr 2014 15:35:12 +1000, Paul Bone <paul at bone.id.au> wrote:
> Mercury developers:
>
> Normally adding test cases is straightforward, and I would like to add
> Sebastian's test case. However this involves concurrency and so output may
> not be printed in the same order on every execution. Normally I might do
> something like sort the lines of the output and compare that with a sorted
> expected output, however this only works for C and Java based grades. It
> doesn't work for C# which (at least on mono on my Linux workstation) can ix
> the output threads within the same line. If any one has any ideas for this
> kind of test I'd be interested. Otherwise I think I'll create a directory
> of tests for concurrency that sort their outputs and are disabled for C#.
Hi Paul,
You need to add your own synchronisation if multiple threads are writing
to the same output stream. If that would perturb the test case then you
can make each thread log to its own data structure and merge them later.
Peter
More information about the reviews
mailing list