diff options
author | Profpatsch <mail@profpatsch.de> | 2023-10-20T12·09+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-10-20T12·16+0000 |
commit | 640f6fdfe4d675427df151fc3405fa3f2ca7c029 (patch) | |
tree | 22203c52fc4013618bdfd480c2e57b0d41ddafb6 /users/Profpatsch/openlab-tools/src | |
parent | 3dba987de4623d903fc6e7d05550b37e57711cdd (diff) |
fix(users/Profpatsch/openlab-tools): really deepseq cache content r/6862
Okay, so I guess you also have to seq the cache and everything in between the IORef and the data. Change-Id: I4c79c99afbd09e83e9d7a01d58b31b36862e4d11 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9807 Reviewed-by: Profpatsch <mail@profpatsch.de> Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
Diffstat (limited to 'users/Profpatsch/openlab-tools/src')
-rw-r--r-- | users/Profpatsch/openlab-tools/src/OpenlabTools.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/users/Profpatsch/openlab-tools/src/OpenlabTools.hs b/users/Profpatsch/openlab-tools/src/OpenlabTools.hs index b63b6a601200..21909368bae7 100644 --- a/users/Profpatsch/openlab-tools/src/OpenlabTools.hs +++ b/users/Profpatsch/openlab-tools/src/OpenlabTools.hs @@ -251,8 +251,8 @@ assertM span f v = case f v of Left err -> appThrowTree span err data Cache a = Cache - { until :: UTCTime, - result :: a + { until :: !UTCTime, + result :: !a } newCache :: a -> IO (IORef (Cache a)) @@ -262,10 +262,10 @@ newCache result = do updateCache :: (NFData a) => IORef (Cache a) -> a -> IO () updateCache cache result' = do - -- make sure we don’t hold onto the world by deepseq-ing - let result = deepseq result' result' + -- make sure we don’t hold onto the world by deepseq-ing and evaluating to WHNF + let !result = deepseq result' result' until <- getCurrentTime <&> ((5 * 60) `addUTCTime`) - _ <- writeIORef cache Cache {..} + _ <- writeIORef cache $! Cache {..} pure () updateCacheIfNewer :: (MonadUnliftIO m, NFData b) => IORef (Cache b) -> m b -> m b |