This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class InnerInterruptionCorrectExample { | |
public static void main(String[] args) throws InterruptedException { | |
// Create a ExecutorService for managing threads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.glovoapp.jvmkit.context.demo.app.models; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class InnerInterruptionTest { | |
public static void main(String[] args) throws InterruptedException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<name>java-opentracing-tutorial</name> | |
<groupId>com.github.yurishkuro</groupId> | |
<artifactId>java-opentracing-tutorial</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<properties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait KVStore[F[_], K, V] { | |
def get(key: K): F[Option[V]] | |
def put(key: K, value: V): F[Unit] | |
} | |
class Dict[F[_]: Monad, K, V](store: KVStore[F, K, V]) { | |
def computeIfAbsent(k: K, absent: => V)(implicit m: Monad[F]): F[V] = { | |
m.flatMap(store.get(k)) { value => | |
m.pure(value.getOrElse(absent)) | |
} |