阅读Play-Slick DBAction 代码,我认为此代码可能包含竞争条件:
object DBAction{
// snip
def apply(r: (RequestWithDbSession) => Result)(implicit app:Application) = {
Action { implicit request =>
AsyncResult {
DB.withSession{ s:scala.slick.session.Session =>
Future(r( RequestWithDbSession(request,s) ))(executionContext)
}
}
}
}
该函数r
在未来某个时间运行,在withSession
返回一个 Future[Result] 之后,并调用session.close()
. 此代码中是否存在竞争条件?