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

Julien Fischer jfischer at opturion.com
Wed Jul 16 17:09:34 AEST 2014


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

Cheers,
Julien.



More information about the reviews mailing list