<commit_before>package tornadofx

import javafx.application.Platform
import javafx.collections.FXCollections
import javafx.concurrent.Task

fun <T> List<T>.observable() = FXCollections.observableList(this)

fun <T> task(func: () -> T) = object : Task<T>() {
    override fun call(): T {
        return func()
    }
}.apply {
    setOnFailed({ Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), exception) })
    Thread(this).start()
}

infix fun <T> Task<T>.success(func: (T) -> Unit): Task<T> {
    Platform.runLater {
        setOnSucceeded { func(value) }
    }
    return this
}

fun runFXSync(action: () -> Unit) {
    // run synchronously on JavaFX thread<commit_msg>Update Lib.kt<commit_after>package tornadofx

import javafx.application.Platform
import javafx.collections.FXCollections
import javafx.concurrent.Task
import java.util.concurrent.CountDownLatch

fun <T> List<T>.observable() = FXCollections.observableList(this)

fun <T> task(func: () -> T) = object : Task<T>() {
    override fun call(): T {
        return func()
    }
}.apply {
    setOnFailed({ Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), exception) })
    Thread(this).start()
}

infix fun <T> Task<T>.success(func: (T) -> Unit): Task<T> {
    Platform.runLater {
        setOnSucceeded { func(value) }
    }
    return this
}

fun runFXSync(action: () -> Unit) {
    // run synchronously on JavaFX thread
{'fraction_non_alphanumeric': 0.13982179575051404, 'fraction_numerical': 0.0, 'mean_word_length': 3.9659863945578233, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1054185', 'n_tokens_mistral': 466, 'n_tokens_neox': 461, 'n_words': 100}