[m-rev.] for review: Add thread.spawn_native/4 and thread.spawn/4.

Julien Fischer jfischer at opturion.com
Wed Jul 16 17:50:58 AEST 2014


On Wed, 16 Jul 2014, Julien Fischer wrote:

>
> Hi,
>
> On Wed, 25 Jun 2014, Peter Wang wrote:
>
>> Branches: master
>> 
>> Most backends already mapped Mercury threads to "native" threads in 
>> spawn/3,
>> but it was and remains an implementation detail.  spawn_native provides
>> that behaviour as a documented feature for programs which require it,
>> including for the low-level C backend.
>> 
>> While we are at it, add a `thread' handle type.  Some future uses
>> include: a place to hold a thread identifier; a handle for a
>> `thread.join' predicate if we want; a place to hold result values or
>> uncaught exceptions if we want.
>> 
>> library/thread.m:
>> 	Add abstract type `thread'.  Currently just a dummy type.
>>
>> 	Add can_spawn_native.
>>
>> 	Add spawn_native/4.  It can report failure to start a thread,
>> 	which was missing from the spawn/3 interface.
>>
>> 	Add spawn/4 to match spawn_native/4, without the native thread
>> 	requirement.
>>
>> 	Make ML_create_exclusive_thread wait for a success code from
>> 	the new thread before continuing.
>> 
>> runtime/mercury_thread.c:
>> 	Make MR_init_thread_inner and MR_setup_engine_for_threads
>> 	return errors instead of aborting on failure.
>> 
>> tests/hard_coded/Mercury.options:
>> tests/hard_coded/Mmakefile:
>> tests/hard_coded/spawn_native.exp2:
>> tests/hard_coded/spawn_native.exp:
>> tests/hard_coded/spawn_native.m:
>> 	Add test case.
>> 
>> NEWS:
>> 	Announce change.
>
> This change has broken compilation of the standard library in the erlang
> grade (or at least uncovered a bug that prevents the standard library
> from compiling in the erlang grade).
>
> Making Mercury/beams/mercury__thread.beam
> Mercury/erls/mercury__thread.erl:207: variable 'STATE_VARIABLE_IO_0_10'
> is unbound
> Mercury/erls/mercury__thread.erl:231: variable 'STATE_VARIABLE_IO_0_8'
> is unbound
> ** Error making `Mercury/beams/mercury__thread.beam'.
> make[1]: *** [libmer_std.install] Error 1
> To clean up from failed install, remove
> /Users/jfischer/Mercury-Workspaces/mercury.local-4/stage2/install_grade_dir.erlang
> make: *** [install_grades] Error 1

I've added a workaround for this in commit 
0997b1317f915ff5f69a7217df8b38a67d6cc39e.
The underlying issue (which remains unfixed) is related to the code we 
generate when cc_multi_equal/2 is called where its arguments are some dummy type.

Cheers,
Julien.




More information about the reviews mailing list