Skip to content

Deprecate Lwt_main.yield and Lwt_unix.yield? #855

Closed

Description

@favonia

This is a suggestion. After talking to @aantron on Discourse, I feel we should officially deprecate yield and related functions using [@@alert deprecate], in hope that one day we will merge the two pools into one.

Activity

  1. cyberhuman commented on May 21, 2021

    @cyberhuman

    How do you yield then? 🤔

  2. favonia commented on May 21, 2021

    @favonia
    ContributorAuthor

    Lwt.pause () will do the job. There are currently two pools in the codebase due to the two almost identical mechanisms, but I believe they can be safely merged once every Lwt_unix.yield () and Lwt_main.yield () is replaced by Lwt.pause ().

  3. aantron commented on May 21, 2021

    @aantron
    Collaborator

    See

    val yield : unit -> unit Lwt.t
    (** [yield ()] is a pending promise that is fulfilled after Lwt finishes
    calling all currently ready callbacks, i.e. it is fulfilled on the next
    “tick.”
    [yield] is similar to {!Lwt.pause} and it exists for historical reason.
    Prefer [pause] in order to stay compatible with other execution
    environments such as js_of_ocaml. *)

    and https://discuss.ocaml.org/t/lwt-pause-versus-yield/7875.

  4. raphael-proust commented on May 25, 2021

    @raphael-proust
    Collaborator

    See #784 for some earlier discussion of this.

    TL;DR:

    • Lwt_main.run treats paused and yielded promises differently: it resolves paused promises twice as often as yielded promises.
    • This is not an intended difference, but it's a significant difference and it may be significant for several binaries.

    I think that, before we release this we should:

    • run the tests of all the opam packages that depend on lwt with the modified lwt (I think this is possible through the opam CI in some way)
    • notify packages that we break or even give them some patches
    • advertise the possibility of the change on discuss (and maybe other channels)

    Then if all of that goes well, we can release. It'll need a "breaking change" mention in the changelog.

    Maybe we could leverage the opam infrastructure to test if we break some of the tests of the opam packages. I think we should do this (if possible), make upstream commits to all possibly broken packages, and we should make a special mention of this in the changelog (and advertise it in advance on discuss too).

  5. favonia commented on May 25, 2021

    @favonia
    ContributorAuthor

    I just updated CHANGES in the #858 but need help in all other actionable items.

  6. raphael-proust commented on May 25, 2021

    @raphael-proust
    Collaborator

    I'll ask some opam wizards about the general test of all dependencies.

  7. favonia commented on Nov 27, 2022

    @favonia
    ContributorAuthor

    Closing this as #917 will complete every actionable items in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions