On 10-12-02 01:19 PM, Graham Fawcett wrote:
Hi folks,

While I'm waiting for something at $WORK to compile, I thought I'd
take a crack at easy issue #42, moving yield and join into the
standard library.

Great! Thanks. I guess it's pretty easy to do now :)

After removing the yield and join keywords from the front/middle ends,
is it enough to just add this to std._task:

  native "rust" mod rustrt {
      fn task_sleep(uint time_in_us);
+    fn upcall_join(task t);
+    fn upcall_yield();
  }

+fn join(task t) {
+    ret rustrt.upcall_join(t);
+}
+
+fn yield() {
+    ret rustrt.upcall_yield();
+}

Might well be enough, yeah. You'll also want to adjust the testcases that twiddle these keywords.

join() seems to work; I don't know how to test yield().

There are a couple testcases (test/run-pass/yield*.rs) but they don't definitively test working / non-working-ness of the feature. Really it's ... *almost* irrelevant as a call: we inject time-based preemption points at loop edges and function calls anyways, and deschedule anything blocked on I/O, do it really only exists if you're interested in "smoothing" execution-interleaving in an unusual context (without adjusting the time-slice). I'm not sure it'll be easy to test in any case.

I see that nothing else in the stdlib calls an upcall_ function; is
this bad form? Should I add task_yield and task_join to
rust_builtin.cpp instead, the way task_sleep is handled?

Yeah, probably. The term "upcall" is sort of vestigial from an earlier iteration of the compiler <-> runtime boundary when we weren't using direct stack-switching calls. Upcalls were structured more like syscalls in C, packing arguments into a structure and entering a generic suspend-me-and-dispatch-upcall routine. That's long gone.

What we currently reserve the (dubious) "upcall" term for is "native calls generated by the compiler". So at present, for symmetry with this rule, adding task_* functions to rust_builtin is better. But only because it is sort of uniform and makes the job of future reorganization of naming more obvious.

-Graydon
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to