#1727 Actor.sleep is not convenient enough

saltnlight5 Sun 11 Dec 2011

Hi there,

I see that there is a sleep method in Actor, but to use it, I have to first do "using concurrent", which I found it a bit user unfriendly. I want to use sleep just to pause system, and it's not in a "concurrent" sense. I think it would make more sense to be in "sys" pod so that user can use more convieniently.

Also, if I were to use a build.fan, I now have to do one more step and add "concurrent" to depends list. It's seem a bit annoying to have a such basic function need.

-Z

brian Mon 12 Dec 2011

We could potentially add it to Env. But sleeping sort of implies some sort of threading which is what Actor deals with. Are you using sleep, but not Actors? Can you explain a bit your use case?

saltnlight5 Mon 12 Dec 2011

Hi Brian, I am little familiar with Actor. But in many case, I would just need to write single threaded programs that simply sleep for some times. Using it in these cases seem odd to referencing Actor.

Sys.sleep would have better naming, but I don't see Sys define, but only Env. So having it there is better than Actor.

You can duplicate the method and leave sleep in Actor too right?

brian Tue 13 Dec 2011

I don't think there is a sleep function in JavaScript, that seems like a good reason why it doesn't belong in sys (correct me if I'm wrong). After thinking about it, still seems like it belongs only in concurrent. But if others chime in and would like to vote for adding it to Env, I can get on board.

qualidafial Tue 13 Dec 2011

Leave it in concurrent, or move it to util. I don't really think this belongs in sys though.

saltnlight5 Tue 13 Dec 2011

@brian,

It's nice to able to run Fantom on different platforms, but running on JavaScript I suppose we just have to live with it's limitation.

Any programming language that doesn't support sleep() seems very lame to me. Fantom has a sleep() function (thank goodness), so the question is where would it be located so that it's most convenient to developers to use it. I have mentioned two reasons above that it's inconvenient.

One nice feature of Fantom is we can run it as script, and when we do this, we tend to write mostly small utility that run as single threaded env. Why force users to lookup the topic of "Actor" in these cases?

helium Wed 14 Dec 2011

Sleep normally suspends the current thread for the specified time. I would be very surprised if it wouldn't be in some concurrency related package.

Login or Signup to reply.