Created
December 24, 2014 04:32
-
-
Save nhibberd/1a528b59c471df741b53 to your computer and use it in GitHub Desktop.
TestingTemporaries
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
case class TestingTemporaries(buffer: java.util.concurrent.ConcurrentLinkedQueue[LocalPath]) | |
object TestingTemporaries { | |
val registered: java.util.concurrent.atomic.AtomicReference[TestingTemporaries] = | |
new java.util.concurrent.atomic.AtomicReference[TestingTemporaries] | |
def localPath: RIO[LocalPath] = ResultT.io { | |
if (registered.compareAndSet(null, TestingTemporaries(new java.util.concurrent.ConcurrentLinkedQueue))) | |
Runtime.getRuntime.addShutdownHook(new Thread(new Runnable { | |
def run: Unit = { | |
// TODO delete all the things | |
} | |
})) | |
val temporaries = registered.get | |
val p = LocalPath(uniqueLocalPath) | |
temporaries.buffer.add(p) | |
p | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment