diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-11-07 22:16:46 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-11-07 22:16:46 +0100 |
commit | 40b9cc1f785eaae352267757ac9e091c25ed0744 (patch) | |
tree | 1c7dec688121c471c2ada361ca407a41ce1c7646 /kvision-modules | |
parent | dec46533acbfa4751337149dcf7b1a67f9bb42fd (diff) | |
download | kvision-40b9cc1f785eaae352267757ac9e091c25ed0744.tar.gz kvision-40b9cc1f785eaae352267757ac9e091c25ed0744.tar.bz2 kvision-40b9cc1f785eaae352267757ac9e091c25ed0744.zip |
Upgrade to Kotlin 1.3.0 final.
Diffstat (limited to 'kvision-modules')
4 files changed, 14 insertions, 7 deletions
diff --git a/kvision-modules/kvision-server-jooby/build.gradle b/kvision-modules/kvision-server-jooby/build.gradle index 952e9a16..b3912c2c 100644 --- a/kvision-modules/kvision-server-jooby/build.gradle +++ b/kvision-modules/kvision-server-jooby/build.gradle @@ -11,6 +11,9 @@ dependencyManagement { dependencies { expectedBy project(":kvision-modules:kvision-common") compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" compile "org.jooby:jooby-lang-kotlin" diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt index 1e19f394..bc182467 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt @@ -22,8 +22,9 @@ package pl.treksoft.kvision.remote import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.GlobalScope import org.jooby.Kooby import org.jooby.Session @@ -64,8 +65,9 @@ actual typealias Profile = CommonProfile /** * A helper extension function for asynchronous request processing. */ +@UseExperimental(ExperimentalCoroutinesApi::class) fun <RESP> Request?.async(block: (Request) -> RESP): Deferred<RESP> = this?.let { req -> - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req) } } ?: throw IllegalStateException("Request not set!") @@ -73,9 +75,10 @@ fun <RESP> Request?.async(block: (Request) -> RESP): Deferred<RESP> = this?.let /** * A helper extension function for asynchronous request processing with session. */ +@UseExperimental(ExperimentalCoroutinesApi::class) fun <RESP> Request?.asyncSession(block: (Request, Session) -> RESP): Deferred<RESP> = this?.let { req -> val session = req.session() - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req, session) } } ?: throw IllegalStateException("Request not set!") @@ -83,11 +86,12 @@ fun <RESP> Request?.asyncSession(block: (Request, Session) -> RESP): Deferred<RE /** * A helper extension function for asynchronous request processing with session and user profile. */ +@UseExperimental(ExperimentalCoroutinesApi::class) fun <RESP> Request?.asyncAuth(block: (Request, Session, Profile) -> RESP): Deferred<RESP> = this?.let { req -> val session = req.session() val profile = req.require(CommonProfile::class.java) as CommonProfile? profile?.let { - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync(start = CoroutineStart.UNDISPATCHED) { block(req, session, profile) } } diff --git a/kvision-modules/kvision-server-spring-boot/build.gradle b/kvision-modules/kvision-server-spring-boot/build.gradle index d235f214..43d8650d 100644 --- a/kvision-modules/kvision-server-spring-boot/build.gradle +++ b/kvision-modules/kvision-server-spring-boot/build.gradle @@ -6,6 +6,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion" compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion" compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" compile "org.springframework.boot:spring-boot-starter:$springBootVersion" diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt index 730288a8..11b848bf 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServer.kt @@ -22,7 +22,6 @@ package pl.treksoft.kvision.remote import kotlinx.coroutines.Deferred -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import org.pac4j.core.context.J2EContext import org.pac4j.core.context.session.J2ESessionStore @@ -52,7 +51,7 @@ actual typealias Profile = CommonProfile * A helper extension function for asynchronous processing. */ fun <RESP> async(block: () -> RESP): Deferred<RESP> = - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync { block() } @@ -69,7 +68,7 @@ fun <RESP> asyncAuth(block: (Profile) -> RESP): Deferred<RESP> { null } return profile?.let { - GlobalScope.coroutinesAsync(Dispatchers.Unconfined) { + GlobalScope.coroutinesAsync { block(it) } } ?: throw IllegalStateException("Profile not set!") |