Grails(18)Grails with Plugin - Executor

Grails(18)Grails with Plugin - Executor
Installation
The way to install the plugin
>grails install-plugin executor

Usage
runAsync closure
     Takes any closure and passes it through to the executorService.execute

callAsync I am not using this.

Examples of Usage
Services
class SomeService{
     def myMethod(){
          …previous steps
          runAsync {
               calculate()
          }
          …do something else...
     }

     def calculate(){
          …snip...
     }
}

Domain
class Book {
     def myNotifyService

     String name

     def afterInsert(){
          runAsync {
               myNotifyService.informLibraryOfCongress(this)
          }
     }
}

References:
http://grails.org/plugin/executor
https://github.com/basejump/grails-executor

http://nitoprograms.blogspot.com/2012/02/async-unit-tests-part-1-wrong-way.html
http://nitoprograms.blogspot.com/2012/02/async-unit-tests-part-2-right-way.html



你可能感兴趣的:(executor)