Comments (4)
I haven't yet tried to run the code, but I believe the problem is that the poll job never blocks. It completely hogs the one core it is running on and due to the way the cooperative scheduler works, the receiver job never gets a change to run—even if there are multiple cores. Note that if you were running this with only a single core, then the deadlock would be quite reasonable, so I think it can be argued that this behavior is fundamental to how a cooperative system works.
If you add something that blocks the poll job, such as
let poll = job{
let counter = ref 0
for i = 0 to 999 do
let! res = Ch.Try.give c ()
if not res then
do! Timer.Global.sleep (TimeSpan.FromSeconds 0.0001)
counter := !counter + 1
printfn "%A" !counter }
the receiver job gets a chance to run. Does the polling job in your actual program also block after a finite number of polling operations?
from hopac.
Now that I have had my first sip of coffee, I noticed there is a bug in the newly introduced Ch.Try.give operation. Just a moment and I'll fix it.
from hopac.
Thanks for reporting the bug and sorry for the trouble!
I only tested the polling operations quickly with F# interactive and should have added some more substantial code to exercise those code paths.
Note that the discussion about polling loops needing to have some blocking operations is something that needs to be kept in mind although it isn't a problem in your example code, because it only does a finite number of polls.
from hopac.
Thanks a lot! This fixes it. And as you described above, the fact that the polling job never yields control means that only the first value given is read. This is expected.
from hopac.
Related Issues (20)
- Add Azure DevOps build HOT 2
- Problems with network stream HOT 9
- Handling exceptions HOT 9
- Stack Overflow in Alt.choose HOT 3
- Fibonacci benchmark fails with Stack Overflow on NET Core, but not on Framework HOT 4
- Production Ready? HOT 5
- IAsyncEnumerable<T> interop HOT 1
- How to convert to task? HOT 6
- ValueTask<T> interop HOT 1
- How to get the build working on Windows? HOT 2
- Stack overflow with recursive job HOT 5
- Is this project dead? HOT 1
- Why do these two code snippets result in different behavior HOT 1
- FSharp.Core 5.0 support HOT 15
- Why does the left side not uncommit after the right side has been chosen when using Alt.prepare? HOT 8
- How can uncaught exception errors be redirected?
- BadImageFormatException HOT 6
- How to conCollect but stop on first exception? HOT 8
- System.Diagnostics.Activity doesn't flow properly with Hopac, resulting in incorrect telemetry correlation
- Example of paranoid function?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hopac.