https://kotlinlang.org logo
#coroutines
Title
# coroutines
u

ursus

11/25/2020, 11:36 PM
for example this
Copy code
private fun generateMac(someUuid: String, base16HexStringKey: String): String {
        val uuidIdBytes = someUuid.toByteArray(UTF_8)
        val keyBytes = base16HexStringKey.toHexByteArray().decodeBase16()

        return hmacSha512(uuidIdBytes, keyBytes).encodeBase16().toHexString()
    }
It just generates hmac of some uuid string ... worth suspending?
u

uli

11/26/2020, 8:51 AM
how would you make this suspend?
u

ursus

11/26/2020, 4:41 PM
I dont know, since its not cancelable, maybe thats the rule of the thumb?
u

uli

11/26/2020, 4:42 PM
yes. if it is asnychronous make it suspend. if it is blocking it is blocking - you can only put it on a background thread in case it takes a relevant amount of time
i.e. if you need to free up the (main?)thread
3 Views