[mercury-users] Re: Handling a timer in Mercury

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Fri Aug 7 10:02:20 AEST 1998


Ralph Becket, you write:
> Just to point out the obvious, languages such as Modula3 and Java (?)
> which have an integral notion of `thread' generally get round this
> sort of thing by having mutexes as primitive datatypes (or, at least,
> part of a standard library that interfaces with the language runtime
> system).
> 
> I know there's work happening on parallel Mercury, but is there any
> carry over/separate work on/intention to move to a threaded Mercury?
> 
> I think threads are a cool thing to have in your language - it makes
> it a much more serious proposition for all sorts of systems and user-
> interface type programming.
> 

As it happens I'm working on thread stuff in my other window right
now.

Here is the basic construct:

:- pred fork(pred(io__state, io__state), pred(io__state, io__state),
		io__state, io__state).
:- mode fork(pred(di, uo) is det, pred(di, uo) is det, di, uo) is cc_multi.

Eg:

main -->
	fork(io__write_string("hello\n"), io__write_string("world\n")).

which will execute the two writes "concurrently".

I'm also working on some companion data-types which will provide
syncronisation and communication facilities.

Watch this space... :-)

Thomas
-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+



More information about the users mailing list