Hi Danny --
As the documentation says, the call simply exits with a return value of
false when interrupted.
This is not very useful. But you can use this to build your own
"reliable" sleep. Put the call in a while loop and count the time it has
been in sleep. Ugly, but should work. Something like:
def reallySleepIMeanIt(millis:long) {
var failed:Boolean = fa;
var timeRemaining:long= millis;
var start:long = 0;
while (timeRemaining > 0) {
start = System.currentTimeMillis();
System.sleep(timeRemaining);
timeRemaining -= (System.currentTimeMillis()-start);
}
}
On 4/3/14, 5:40 AM, Danny Munera wrote:
Hello all,
I'm using the function System.sleep() to activate some functionality
in my project to be executed each X ms. However, I have some strange
behavior in this function, because frequently it is returning with
false (interrupted), and the functionality is not correctly executed.
I'm getting lots of messages "cannot execute sleep".
I've read the documentation of the sleep function, but i didn't find
any clue to fix this problem. I also implemented a simple example
using only the sleep function and It works well, but when I use the
sleep in my code It doesn't work. I have no idea where I should start
to search the cause of the problem.
Could you give me some suggestion about how to find the cause of this
problem?
public def interTeamActivity(st:PlaceLocalHandle[ParallelSolverI(sz)],
seed:Long {
while (!interTeamKill) {
if (!System.sleep(interTeamInterval)){
Console.OUT.println(here+" interTeamActivity error: cannot execute
sleep");
continue;
}
interTeamComm(st, seed);
}
Regards,
Danny MĂșnera
------------------------------------------------------------------------------
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users