Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
package datasizeformatter | |
import kotlin.math.abs | |
import kotlin.math.pow | |
import kotlin.math.roundToLong | |
/** | |
* Format a human-readable representation of data size, in binary base form. | |
* e.g. 1024 -> 1 KiB | |
* @param byteCount The number of bytes to represent in human-readable form. `Long.MIN_VALUE` is unsupported. |
A lot of Kotlin features can be traced back to functional programming languages, eg
However, Kotlin is missing many incredibly useful data types that are ubiquitous in functional programming languages, eg Either, Try etc.
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Add this as a debug manifest so the permissions won't be required by your production app --> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
<uses-permission android:name="android.permission.WAKE_LOCK" /> | |
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | |
</manifest> |
import kotlinx.coroutines.* | |
import kotlin.coroutines.* | |
/** | |
* Scope interface to control (pause & resume) timeout | |
*/ | |
interface TimerScope : CoroutineScope { | |
fun pause() | |
fun resume() | |
} |
import com.google.protobuf.gradle.protobuf | |
import com.google.protobuf.gradle.protoc | |
plugins { | |
java | |
idea | |
id("com.google.protobuf") version "0.8.7" | |
} | |
repositories { |
/* | |
* The MIT License | |
* | |
* Copyright (c) 2016 Andreas Ahlenstorf | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
@Retention(AnnotationRetention.BINARY) | |
@Target(AnnotationTarget.CLASS) | |
annotation class ValueClass |
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="be.rijckaert.tim.disableanimations"> | |
<!-- Place this permission in your debug folder --> | |
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/> | |
</manifest> |
// Porting of https://gist.github.com/jdegoes/dd66656382247dc5b7228fb0f2cb97c8 | |
typealias UserID = String | |
data class UserProfile(val name: String) | |
// The database module: | |
interface DatabaseService { | |
suspend fun dbLookup(id: UserID): UserProfile | |
suspend fun dbUpdate(id: UserID, profile: UserProfile) | |
} |