/Patrik
> --
> You received this message because you are subscribed to the Google Groups "Akka User List" group.
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
>
> To unsubscribe from this group, send email to akka-user+unsubscribe@googlegroups.com.
> Is it possible that even with cancel I get something executed?
Well, obviously there is a race between cancellation and running: if it has started running, you cannot cancel it anymore.
> Interestingly the first task which was never executed
> is not executed upon shutdown.
>
You mean in the code below? You canceled it, hence it will not be run.
> I need to shut this down because its a database task and at some point
> I have to close the connection without anything
> trying to access it again.
>
The code below prints
scala> testShutdown
still running immediate
still running immediate
shutdown
and if I remove the cancels.foreach() and the following sleep():
scala> testShutdown
still running immediate
still running immediate
shutdown
scala> still running immediate
still running delay
Here you can see that the tasks are executed exactly once after the shutdown is initiated. Keep in mind that the scheduler is shutdown only after all actors in the ActorSystem have stopped (only four in this case), not necessarily before system.shutdown() returns. You can use system.awaitTermination() if you need to be sure.
Regards,
Roland
Roland Kuhn
Typesafe – The software stack for applications that scale.
twitter: @rolandkuhn
--
>>>>>>>>>> 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+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.