开发者

scala specs don't exit when testing actors

I'm trying to test some actors using scala specs. I run the test in IDEA or Maven (as junit) and it does not exit. Looking at the code, my test fi开发者_开发百科nished, but some internal threads (scheduler) are hanging around. How can I make the test finish?


Currently this is only possible by causing the actor framework's scheduler to forcibly shut down:

scala.actors.Scheduler.impl.shutdown

However, the underlying implementation of the scheduler has been changing in patch-releases lately, so this may be different, or not quite work with the version you are on. In 2.7.7 the default scheduler appears to be an instance of scala.actors.FJTaskScheduler2 for which this approach should work, however if you end up with a SingleThreadedScheduler it will not, as the shutdown method is a no-op

This will only work if your actors are not waiting on a react at that time

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜