digitalmars.D.learn - actors library?
- Xan xan (7/7) Jan 23 2012 Hi.
- Timon Gehr (3/10) Jan 23 2012 std.concurrency is an actors library.
- Xan xan (8/22) Jan 24 2012 Something like
- Dejan Lekic (4/4) Jan 24 2012 Xan, read this article please:
- xancorreu (5/9) Jan 24 2012 I read it and **after** I post the question. I don't know how
- Timon Gehr (59/69) Jan 24 2012 std.concurrency is an implementation of the actor model.
- xancorreu (6/76) Jan 25 2012 Thanks Gehr for your examples. Very illustrative.
Hi. Is there any actors library in D. Spawn and etc is ok, but I want more high-level thing and actors it's the best I get, I think. I searched and nothing. I'm interested in D 2.0 or 1.0. Whatever! Thanks in advace, Xan.
Jan 23 2012
On 01/23/2012 08:01 PM, Xan xan wrote:Hi. Is there any actors library in D. Spawn and etc is ok, but I want more high-level thing and actors it's the best I get, I think. I searched and nothing. I'm interested in D 2.0 or 1.0. Whatever! Thanks in advace, Xan.std.concurrency is an actors library. What exactly do you mean when you say more high-level?
Jan 23 2012
Something like Class MyActor : Actor { receive { case i int: writeln("Received integer: ", i) } } pseudocode.... 2012/1/23 Timon Gehr <timon.gehr gmx.ch>:On 01/23/2012 08:01 PM, Xan xan wrote:Hi. Is there any actors library in D. Spawn and etc is ok, but I want more high-level thing and actors it's the best I get, I think. I searched and nothing. I'm interested in D 2.0 or 1.0. Whatever! Thanks in advace, Xan.std.concurrency is an actors library. What exactly do you mean when you say more high-level?
Jan 24 2012
Xan, read this article please: http://www.informit.com/articles/article.aspx?p=1609144 You have exactly what you are looking for in the D runtime and standard library.
Jan 24 2012
Al 24/01/12 13:37, En/na Dejan Lekic ha escrit:Xan, read this article please: http://www.informit.com/articles/article.aspx?p=1609144 You have exactly what you are looking for in the D runtime and standard library.I read it and **after** I post the question. I don't know how std.concurrency is related to actors model. Can you enlight me? Thanks, Xan.
Jan 24 2012
On 01/24/2012 07:51 PM, xancorreu wrote:Al 24/01/12 13:37, En/na Dejan Lekic ha escrit:std.concurrency is an implementation of the actor model. 'Actor model' does not imply 'Object Oriented'. Example 1: import std.stdio, std.concurrency; void myActor() { try { for(;;){ receive( (int i){ writeln("Received integer: ",i); } ); } }catch(Exception e){ // cleanup } } void main() { auto actor = spawn(&myActor); foreach(i;0..10) actor.send(i); } Example 2: import std.stdio, std.concurrency; import core.thread; alias Thread.sleep sleep; void ping() { Tid pong; try { for(;;){ receive( (string s){ writeln("ping received ",s); sleep(dur!"seconds"(1)); pong.send("ping"); }, (Tid newPong){ pong = newPong; } ); } }catch(Exception e){} } void pong(Tid ping) { try { ping.send("pong"); for(;;){ receive( (string s){ writeln("pong received ",s); sleep(dur!"seconds"(1)); ping.send("pong"); } ); } }catch(Exception e){} } void main() { auto a1 = spawn(&ping); auto a2 = spawn(&pong,a1); a1.send(a2); sleep(dur!"seconds"(10)); }Xan, read this article please: http://www.informit.com/articles/article.aspx?p=1609144 You have exactly what you are looking for in the D runtime and standard library.I read it and **after** I post the question. I don't know how std.concurrency is related to actors model. Can you enlight me? Thanks, Xan.
Jan 24 2012
Thanks Gehr for your examples. Very illustrative. I wanted what you do in example 1 like a library. It's easy import actors library than to define your own actors (class). Thanks, Xan. Al 24/01/12 21:11, En/na Timon Gehr ha escrit:On 01/24/2012 07:51 PM, xancorreu wrote:Al 24/01/12 13:37, En/na Dejan Lekic ha escrit:std.concurrency is an implementation of the actor model. 'Actor model' does not imply 'Object Oriented'. Example 1: import std.stdio, std.concurrency; void myActor() { try { for(;;){ receive( (int i){ writeln("Received integer: ",i); } ); } }catch(Exception e){ // cleanup } } void main() { auto actor = spawn(&myActor); foreach(i;0..10) actor.send(i); } Example 2: import std.stdio, std.concurrency; import core.thread; alias Thread.sleep sleep; void ping() { Tid pong; try { for(;;){ receive( (string s){ writeln("ping received ",s); sleep(dur!"seconds"(1)); pong.send("ping"); }, (Tid newPong){ pong = newPong; } ); } }catch(Exception e){} } void pong(Tid ping) { try { ping.send("pong"); for(;;){ receive( (string s){ writeln("pong received ",s); sleep(dur!"seconds"(1)); ping.send("pong"); } ); } }catch(Exception e){} } void main() { auto a1 = spawn(&ping); auto a2 = spawn(&pong,a1); a1.send(a2); sleep(dur!"seconds"(10)); }Xan, read this article please: http://www.informit.com/articles/article.aspx?p=1609144 You have exactly what you are looking for in the D runtime and standard library.I read it and **after** I post the question. I don't know how std.concurrency is related to actors model. Can you enlight me? Thanks, Xan.
Jan 25 2012