raphael-proust on master
Lwt_domain: update to domainsli… Remove workflow that is not use… Merge pull request #971 from Su… (compare)
Lwt_unix.sleep, they start some background I/O operation, that knows how to tell
Lwt_main.runthat it finished
Lwt_main.runwill happen later)
Lwt.wakeup_later), its just straight line ocaml code to load the callback list from the formerly pending promise, replace its state by resolved, and then run each callback in the list
Lwt.wakeup_latertraversing all these lists that are stored with pending promises
readfrom a file, a helper in lwt creates a promise for you. you can then attach your own callbacks to it
Lwt_unix.read, for example)
read(2)operation. when that completes, it resolves the promise it gave you, triggering what i just described above
Lwt_main.runis to block the process until the next such I/O promise gets resolved
Lwt_main.runputs the process to sleep. the real underlying I/O is meanwhile still running, in parallel
Lwt_main.runwakes up the process, resolves the associated promise, which triggers another phase of running as much code as possible
Lwt_main.yield ()btw is just the most trivial I/O promise possible.
yieldcreates a pending promise, then puts a function into the back of
Lwt_main.run's queue to resolve it right away. this allows
Lwt_main.runto first run any code in callbacks associated with other I/O promises that have resolved recently, then
yield ()promise, after draining the rest of the queue
I haven't followed the tutorial, I thought I'll just jump in and pick it up as I go :sweat_smile: , clearly a suboptimal approach. I was too fixated on solving the problem at hand rather than looking at the bigger picture.
I'll go through the tutorial now.
I think I follow most of your explanation. That said,
puts the process to sleep. the real underlying I/O is meanwhile still running, in parallel
has me a bit confused. Are there multiple OS processes here, with one sleeping and another one doing IO?
g, the answer is yes, you have to do it manually. however, ideally, this should be very rare
Lwt. the operators are provided by
let open Lwt.Infix in ...
Orbifxwhat's your address?