[erlang-questions] fire off a task via erlang

Mazen Harake mazen.harake@REDACTED
Fri May 14 12:56:13 CEST 2010


Hi, The pattern I usually implement for this kind of behaviour is an ETS 
table which is sorted by the time of the next event and then I poll it 
every second. If the first element is not triggered then nothing else 
should trigger either (because it is sorted). When it does trigger I 
immediately check the next element until I reach an element in the table 
that is in the future or the end of the table. This works well with 
repeating events as well because you can just "reschedule" a new event 
or just insert as many as you want for future use.

This might meet your requirements.

/Mazen

On 13/05/2010 18:43, Wes James wrote:
> On Thu, May 13, 2010 at 9:34 AM, Evans, Matthew<mevans@REDACTED>  wrote:
>    
>> You could certainly use the timer module. But there is a small performance overhead.
>>
>> Maybe a better choice would be each task to be its own gen_server and use erlang:send_after(Delay,self(),Message).
>>
>> IRC that has a lower overhead. You would call the first instance of send_after in the init function, and then the message would be caught by handle_info, where you restart the timer.
>>      
> Matt,
>
> I was wondering about erlang's concurrency capabilities too.  I've
> only done some "sequential" erlang.
>
> thx,
>
> -wes
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>    

---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list