Skip to content

Instantly share code, notes, and snippets.

View vengateshm's full-sized avatar
🏠
Working from home

Vengatesh M vengateshm

🏠
Working from home
View GitHub Profile
@vengateshm
vengateshm / MainActivity.kt
Last active September 24, 2021 17:48
Ktor client on Android
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import io.ktor.client.*
import io.ktor.client.engine.android.*
import io.ktor.client.features.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.logging.*
@vengateshm
vengateshm / ParallelExecution.kt
Created September 24, 2021 04:32
Execute coroutines in parallel and wait for result of all coroutines.
import kotlinx.coroutines.*
import kotlin.random.Random
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
val time = measureTimeMillis {
runBlocking {
val coffeePowder = async {
println("Grinding coffee bean...")
grindCoffeeBeans()
@vengateshm
vengateshm / CoroutinesPractice.kt
Created September 23, 2021 17:28
This file has snippets of different coroutines concept
import kotlinx.coroutines.*
import kotlin.random.Random
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
// measureCoroutineExecutionTime()
// catchExceptionOfLaunchCoroutineBuilder()
// catchExceptionOfAsyncCoroutineBuilder()
// fireAndForget()
// getReturnValueFromCoroutine()