Skip to content

Instantly share code, notes, and snippets.

@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
import com.twitter.concurrent.{Offer, Broker}
import com.twitter.conversions.time._
import com.twitter.finagle._
import com.twitter.util._
object Reeval {
/** Given a function `mkVar => Var[A]` and a time interval create another `Var[A]` that:
* - initially has a value equal to the value of evaluated `mkVar`
* - passes all updates of created var to the observers