Skip to content

Commit

Permalink
shutdown + set fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebceu4 committed Nov 7, 2017
1 parent f04c986 commit d495b95
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import scala.collection.JavaConverters._

import com.google.common.cache.CacheBuilder

class ExpirationSet[T](expirationTimeMilis: Long) extends scala.collection.mutable.Set[T]{
class ExpirationSet[T <: Object](expirationTimeMilis: Long) extends scala.collection.mutable.Set[T]{
private val emptyItem = new Object()

private var inner = CacheBuilder.newBuilder()
.expireAfterWrite(expirationTimeMilis, TimeUnit.MILLISECONDS)
.build[T, Boolean]()
.build[T, Object]()

override def +=(elem: T): ExpirationSet.this.type = {
inner.put(elem, true)
inner.put(elem, emptyItem)
this
}

Expand Down

0 comments on commit d495b95

Please sign in to comment.