Erlang/OTP Forums

Author Message

<  Erlang  ~  Begginer, need help with syntax of receive, after

gemen1
Posted: Fri Jul 16, 2010 9:32 am Reply with quote
Joined: 16 Jul 2010 Posts: 3
Hi, I have currently the following erlang code



Code:
-define(tag, normal).

normal(_Self, Data) ->
         someUnit_signal:send(?tag, fun(_) -> {?tag, Data} end).

waitfor() ->
    {ok, {_, Data}} = someUnit_signal:wait(?tag,
                                    fun({?tag, _}) -> true end,10000), Data.



I want to convert this so that I don't use the class
someUnit_signal, I just want to do a bang between this functions. This is how far I've got

Code:
-define(tag, normal).
normal(Self, Data) ->
Self ! {Data}.

waitfor()->
receive
????
after 10000->{timeout}
end.


I am currently lost on what to write in the receive case, I just want the function to wait some time(10000 ms) and send back the Data variable that the function normal receives. So if anybody could fill in this case I would be very greatful


[/code]
View user's profile Send private message
zajda
Posted: Sat Jul 17, 2010 9:06 am Reply with quote
User Joined: 22 Aug 2009 Posts: 83
here is very good tutorial http://www.erlang.org/doc/getting_started/conc_prog.html#id2263965
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum