kotlinx-coroutines-core / kotlinx.coroutines.experimental / Job
interface Job : Element
(source)
A background job. A job can be cancelled at any time with cancel function that forces it to become completed immediately.
It has two states:
kotlinx-coroutines-core / kotlinx.coroutines.experimental / Job
interface Job : Element
(source)
A background job. A job can be cancelled at any time with cancel function that forces it to become completed immediately.
It has two states:
kotlinx-coroutines-core / kotlinx.coroutines.experimental / Job
interface Job : Element
(source)
A background job. A job can be cancelled at any time with cancel function that forces it to become completed immediately.
It has two states:
// UPDATE: Everyone finding this gist via Google! | |
// Modern kotlinx.coroutines has out-of-the-box support for asyncLazy with the following expression: | |
// val myLazyValue = async(start = CoroutineStart.LAZY) { ... } | |
// Use myLazyValue.await() when you need it | |
// ---------------- public api ---------------- | |
public interface AsyncLazy<out T> { | |
public suspend fun value(): T | |
public fun isInitialized(): Boolean |
import java.util.concurrent.CompletableFuture | |
// ====================================================================================================== | |
// demo the problem with naive await implementation | |
fun main(args: Array<String>) { | |
val n: Int = 100000 | |
var actualCount = 0; | |
async<Unit> { | |
repeat(n) { // repeat n times |
import java.io.InputStream | |
import java.nio.ByteBuffer | |
import java.nio.channels.AsynchronousFileChannel | |
import java.nio.channels.CompletionHandler | |
import java.nio.file.Path | |
import java.nio.file.Paths | |
import java.nio.file.StandardOpenOption.CREATE | |
import java.nio.file.StandardOpenOption.WRITE | |
import java.time.Instant | |
import java.util.concurrent.CompletableFuture |
/* | |
* QDS - Quick Data Signalling Library | |
* Copyright (C) 2002-2015 Devexperts LLC | |
* | |
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | |
* If a copy of the MPL was not distributed with this file, You can obtain one at | |
* http://mozilla.org/MPL/2.0/. | |
*/ | |
package com.devexperts.util; |
import java.util.BitSet; | |
/** | |
* @author Roman Elizarov | |
*/ | |
public class Regex { | |
private final int n; // number of actual chars in pattern (w/o *) | |
private final char[] cs; // actual chars in pattens (w/o *) | |
private final boolean[] rs; // true when * applies | |
private final int[] fs; // transitive closure of match, given that an empty string matches x* |