<ehirdoy>
@hannes, the purpose is that, I got a function to implement, its type is, var mysleep () : unit -> unit, but OS.Time.sleep_ns reutrns unit Lwt.t. How can I implement mysleep ()?
<hannes>
ehirdoy: I don't understand your goal. since MirageOS uses the asynchronous task library lwt, blocking operations are done inside Lwt.t.
mort___ has joined #mirage
<hannes>
ehirdoy: in OCaml, there's Unix.sleep (blocking, not as part of lwt). Such a thing is not available in MirageOS.
<ehirdoy>
@hannes, the original code uses Unix.sleep. but its preventing hvt.
<ehirdoy>
I'm getting rid of some Unix dependencies for MirageOS'rization now.
<hannes>
ehirdoy: in MirageOS, there's no other sleep.
<ehirdoy>
Currently I'm working around with busyloop but.....
mort___ has quit [Client Quit]
<hannes>
so, if you want to sleep you'll need to be in the Lwt.t monad.
<ehirdoy>
how can this give up CPU for a few sec to let other tasks being done?
<hannes>
hmm?
<hannes>
OS.Time.sleep_ns : int64 -> unit Lwt.t does indeed yield until the amount of nanoseconds is slept. during this time, other Lwt tasks are executed
<ehirdoy>
yes, but it returns unit Lwt.t instead of "unit"
<ehirdoy>
well, I can say, I may want Lwt.val_of_lwt (Lwt.return 42) == 42
<hannes>
yes, since lwt is used. I don't think I understand what you want to achieve..
<ehirdoy>
am I wrong from the starting point??? I seem to want this kind of function, Lwt.val_of_lwt_t (), though....
<hannes>
I'm not sure I understand
<Drup>
ehirdoy: You are taking this from the wrong direction, yes
<Drup>
Do you know what Lwt is for, and how to use it ?
<Drup>
If not, I suggest you read Lwt's tutorial
<hannes>
in "pure" OCaml, there's blocking semantics -- Unix.sleep waits for the delay. This is fine on e.g. Unix with multiple (posix)threads to build "concurrent" programs.
<ehirdoy>
I have kind of understanding, but the issue is that, there's a function prototype which returns "unit"
<Drup>
What's the context ?
<ehirdoy>
If I use Lwt in a func, it cannot return "unit" anymore
<hannes>
on MirageOS, we settled to use lwt (we don't have any posix threads around) to allow multiple tasks. We have a single core, which means if we block in one task, we'd like other tasks to be able to do some computations.
<Drup>
You will not get a lwt-compatible sleeping function that returns unit. It's not happening and you are having a strong case of XY problem :)
Haudegen has quit [Remote host closed the connection]
<Drup>
So, tell us the actual problem instead of your intended solution.
<hannes>
ehirdoy: you'll need to adapt the signature and move this into the Lwt.t monad if you want to use it on MirageOS.
<Drup>
You will have to change your function to `(key * value) array -> (key * value) array Lwt.t`, or get rid of the sleeping (which ... probably shouldn't be there)
<ehirdoy>
@Drup, if so all can make sense, then
<ehirdoy>
So you means, once you use Lwt, all IO is Lwt.t
<Drup>
yes
<hannes>
ehirdoy: yes
<ehirdoy>
Good!! Then, I'll try to modify the protope to afford Lwt.t, then. Thank you for your patience ;)
mort___ has joined #mirage
Haudegen has joined #mirage
twopoint718 has joined #mirage
mort___ has quit [Quit: Leaving.]
mort___ has joined #mirage
twopoint718 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jnavila has joined #mirage
twopoint718 has joined #mirage
mort___ has quit [Quit: Leaving.]
twopoint718 has quit [Read error: Connection reset by peer]
mort___ has joined #mirage
Haudegen has quit [Remote host closed the connection]