Hi Gary,

On Fri, Aug 26, 2016 at 6:17 PM, Gary Struthers <agilej...@earthlink.net>
wrote:

> Thanks Konrad, but I posted because I tried scheduleOnce and got no delay
>
> scheduleOnce(logger.debug("1 currentTimeMillis {}", System.
> currentTimeMillis()), FiniteDuration(100, MICROSECONDS))
>
> scheduleOnce(logger.debug("2 currentTimeMillis {}", System.
> currentTimeMillis()), FiniteDuration(100, MILLISECONDS))
>
> scheduleOnce(logger.debug("3 currentTimeMillis {}", System.
> currentTimeMillis()), FiniteDuration(100, SECONDS))
>
> scheduleOnce(logger.debug("4 currentTimeMillis {}", System.
> currentTimeMillis()), FiniteDuration(100, MINUTES))
>
> scheduleOnce(logger.debug("5 currentTimeMillis {}", System.
> currentTimeMillis()), FiniteDuration(100, DAYS))
>

Since logger.debug(...) returns Unit, you just scheduled the same timer
with the key of the value "Unit" 5 times and not doing anything on the
onTimer callback.

Proper use of this API is

   scheduleOnce("myTimer", FiniteDuration(100, MILLISECONDS))

Then override onTimer where you will get the key so you can do multiple
things depending on which timer fired. You can use the same key to cancel
or reschedule timers.

-Endre


> Produced
>
> 2016-08-26 09:04:15,111 DEBUG ... akka.actor.default-dispatcher-3 - 1
> currentTimeMillis 1472227455110
>
> 2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 2
> currentTimeMillis 1472227455114
>
> 2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 3
> currentTimeMillis 1472227455114
>
> 2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 4
> currentTimeMillis 1472227455114
>
> 2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 5
> currentTimeMillis 1472227455114
>
> Akka version 2.4.9
>
>
> Gary
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/
> current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to