Skip to content

Lwt_pqueue not documented #135

Closed
Closed

Description

@antoine1fr

Hello,

I was looking for a queue implementation for a producer-consumer system when I found Lwt_pqueue on Lwt's API documentation.

Unfortunately it isn't documented at all.

What is it used for in Lwt?

Activity

  1. aantron commented on Jul 3, 2016

    @aantron
    Collaborator

    It is a priority queue used only internally in Lwt_engine to sort threads waiting for timeouts.

    The interface apparently has nothing to do with Lwt, i.e. it is just a regular priority queue that could be implemented by any library, and is not aware of anything Lwt provides, nor is mentioned in any other Lwt signature. This makes me think that this module should not be part of the Lwt API.

    Among OPAM packages depending on Lwt, it is used only in project mirage-platform.

    I suggest that we document this module as deprecated, and remove it from the API in the future (not soon – have to give non-OPAM users a chance to react). @talex5, what do you think?

  2. aantron commented on Jul 3, 2016

    @aantron
    Collaborator

    @antoine1fr As for producer-consumer systems, if this is still an issue, you may want to look at Lwt_stream, or the separate, but quite nice, Lwt_pipe. Depending on your needs, you can also roll your own using Lwt_condition + Lwt_mutex + any data structure you want, as we discussed in the other issue :)

  3. talex5 commented on Jul 3, 2016

    @talex5
    Contributor

    Not sure about this. The same argument could be used about Lwt_sequence. They're both commonly-useful data structures and neither depends on Lwt. Both could be moved to a general utility library (or even to the standard library).

    I see I used Lwt_pqueue in CueKeeper too: https://github.com/talex5/cuekeeper/blob/master/tests/test.ml#L19

    Perhaps we could suggest adding these to the standard OCaml library and remove them from Lwt when/if the stdlib provides an alternative? I agree Lwt isn't really the right place to define them, but they've been there for a while and aren't really doing any harm. Documentation would be good, though...

  4. aantron commented on Jul 3, 2016

    @aantron
    Collaborator

    Lwt_sequence would be nice to move out too, but unlike Lwt_pqueue, it is used in other places in the API (example) – although, perhaps, it shouldn't be. Lwt_pqueue is AFAICT purely an implementation detail at this point, when considering only Lwt.

    Perhaps we could suggest adding these to the standard OCaml library and remove them from Lwt when/if the stdlib provides an alternative? I agree Lwt isn't really the right place to define them, but they've been there for a while and aren't really doing any harm. Documentation would be good, though...

    I think this is a good idea. It's probably best to mark Lwt_pqueue deprecated now, to discourage its use in new code, but I will keep it around for the foreseeable future. In the meantime, we can try to get it added to stdlib or factor it out somehow. Lwt_sequence probably should get similar treatment, but I'd have to look into it more carefully first due to its usage in the API.

    I'll add docs in the meantime as well.

  5. aantron commented on Jul 4, 2016

    @aantron
    Collaborator

    See attached commit. The docs should also soon be visible here.

    EDIT: looking into the broken external links...

    @talex5 I do an OPAM search before removing anything, so I will let you know if I start heading towards actually getting rid of this module. It won't be soon, and you shouldn't have to do anything in the meantime.

  6. talex5 commented on Jul 4, 2016

    @talex5
    Contributor

    Thanks (and the new docs look good!).

  7. added a commit that references this issue on Jul 8, 2016
  8. added a commit that references this issue on Oct 16, 2025
    c86cba3
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions