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 concurrent | |
import ( | |
"sync/atomic" | |
) | |
type Ref[A any] interface { | |
Get() A | |
Set(a A) | |
UpdateAndGet(f func (A) (A)) A | |
GetAndSet(a A) A |
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 single_routine | |
import ( | |
"log" | |
"sync" | |
"sync/atomic" | |
) | |
type deferred[B any] struct { | |
b B |
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 org.http4s.RequestPrelude | |
import org.typelevel.ci.CIString | |
object SegmentAllowList { | |
def fromAllowList(set: Set[CIString])(req: RequestPrelude): String = { | |
classifier(req)((s: String) => if (set.contains(CIString(s))) SegmentFilter.LeaveAsIs else SegmentFilter.star) | |
} |
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 cats.syntax.all._ | |
import cats.effect._ | |
import fs2._ | |
import fs2.io.net._ | |
import com.comcast.ip4s._ | |
object CheatApp extends IOApp { | |
val parallelism = Int.MaxValue |
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 io.chrisdavenport.softcancel | |
import cats.effect._ | |
import cats.effect.std._ | |
import cats.syntax.all._ | |
object SoftCancel { | |
def makeSoftCancelable[F[_]: Concurrent, A](fa: F[A], supervisor: Supervisor[F]): F[A] = { | |
supervisor.supervise(fa) |
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 cats.effect._ | |
import cats.syntax.all._ | |
import java.util.concurrent.atomic.AtomicReference | |
import scala.annotation.tailrec | |
trait UnsafeRef[A]{ | |
def get: A | |
def set(a: A): Unit | |
def getAndSet(a: A): A |
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 scala.annotation.tailrec | |
import scala.collection.immutable.LongMap | |
import java.util.concurrent.atomic.AtomicReference | |
import cats.effect._ | |
import cats.syntax.all._ | |
trait UnsafeDeferred[F[_], A] extends cats.effect.kernel.DeferredSource[F, A]{ | |
def complete(a: A): Boolean | |
} |
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
object Winch { | |
// https://nodejs.org/api/tty.html | |
case class Size(cols: Int, lines: Int) | |
def build[F[_]: Async]: Resource[F, fs2.concurrent.Signal[F, Size]] = | |
Resource.eval(getCurrentSizeExternal).flatMap{ | |
Stream.repeatEval(singleEvent >> getCurrentSizeExternal) | |
.holdResource(_) | |
} |
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 cats._ | |
import cats.effect.{Sync, Async} | |
import cats.effect.kernel.MonadCancel | |
import cats.~> | |
// Like Deferred except we don't try to do anything for multiple readers/writers. | |
// The expectation is that this will ONLY be used to write once | |
// While one fiber will wait for a callback eventually. | |
// Anything else results in failure. | |
final class RWDeferred[F[_]: Async, A] private ( |
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 io.chrisdavenport.http4s.logging | |
import cats._ | |
import cats.syntax.all._ | |
import cats.data._ | |
import cats.effect._ | |
import cats.effect.syntax.all._ | |
import org.http4s._ | |
import com.comcast.ip4s._ | |
import java.time.format.DateTimeFormatter |
NewerOlder