@@ -382,7 +382,7 @@ showEventType = \case
382 EventCoincidence _ -> "EventCoincidence"
382 EventCoincidence _ -> "EventCoincidence"
384data EventSubscribed a
384data EventSubscribed a
385− = EventSubscribedRoot !(RootSubscribed a)
385+ = EventSubscribedRoot {-# NOUNPACK #-} (RootSubscribed a)
386 | EventSubscribedNever
386 | EventSubscribedNever
387 | forall b. EventSubscribedPush !(PushSubscribed b a)
387 | forall b. EventSubscribedPush !(PushSubscribed b a)
388 | forall k. (GCompare k, a ~ DMap k) => EventSubscribedMerge !(MergeSubscribed k)
388 | forall k. (GCompare k, a ~ DMap k) => EventSubscribedMerge !(MergeSubscribed k)
@@ -765,6 +765,10 @@ subscribe e ws = do
765 liftIO $ subscribeEventSubscribed subd ws
765 liftIO $ subscribeEventSubscribed subd ws
766 return subd
766 return subd
768+noinlineFalse :: Bool
769+noinlineFalse = False
770+{-# NOINLINE noinlineFalse #-}
768getRootSubscribed :: Root a -> EventM (RootSubscribed a)
772getRootSubscribed :: Root a -> EventM (RootSubscribed a)
769getRootSubscribed r = do
773getRootSubscribed r = do
770 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
774 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
@@ -779,6 +783,7 @@ getRootSubscribed r = do
779 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
783 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
780 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
784 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
781 addFinalizer subscribed $ do
785 addFinalizer subscribed $ do
786+ when noinlineFalse $ putStr "" -- For some reason, without this line, the finalizer will run earlier than it should
782-- putStrLn "Uninit root"
787-- putStrLn "Uninit root"
784 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed
789 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed