Re: Threads [Was: Re: 64 bit euphoria]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Patrick Barnes wrote:
> 
> On 4/26/05, Pete Lomax <petelomax at blueyonder.co.uk> wrote:
> > OK: GENERAL QUESTION TO ALL:
> >
> > If there was something you wanted threads for, what would it look like
> > in your ideal snippet of Euphoria code?
> 
> Ideally, a 'thread' would be similar to a procedure or function
> declaration. A few other things like semaphore (wait and signal) and
> mutex support would be nice too.

How about something like... :

sequence data
integer mutex_lock, print_data_id, highest_id
mutex_lock = 0

-- data gets set...

procedure print_data()
    mutex_lock += 1
    for i=1 to length(data) do
        print data[1]
    end for
    mutex_lock -= 1
end procedure
print_data_id = routine_id("print_data")

function highest()
    integer max
    mutex_lock -= 1
    for i=1 to length(data) do
        if data[i]> max then
            max = i
        end if
    end for
    return data[max]
    mutex_lock -= 1
end function
highest_id = routine_id("highest")

call_thread_proc(print_data_id)
call_thread_func(highest_id)
wait_for(mutex_lock = 0)

and use procedures and functions as threads to keep down the amount of new
syntax rules we'd have to add. However, I VERY rarely use threads so I don't know
the feasibility of this.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu