Effect CommunityEC
Effect Community3y ago
13 replies
imagio

Questions about Scope and Fork in Programming

I'm still a bit unclear about the mechanics of Scope and fork so I've got a few questions

1. How does the "global scope" work? Is there a way to get all the fibers running in the global scope? For example to stop anything started with forkDaemon when it's time for the app to shutdown.
2. I use Layer.buildWithScope to build a single runtime I pass around my app to execute effects but I'm a bit confused about its behavior. Why doesn't buildWithScope remove Scope from R? How is the provided scope accessible to the services constructed by a layer using buildWithScope?
3. If I use Layer.buildWithScope will a forkDaemon from layer construction be attached to the global scope or to the specified scope?
4. If I want to ensure that all my "long running processes" are attached to the scope used by my global runtime how can I provide that scope in all the places that need it?
Was this page helpful?