Skip to content

Deprecate the Lwt_unix.async_method machinery and eventually remove it #572

@aantron

Description

@aantron

Here is a description of it:

(** For system calls that cannot be made asynchronously, Lwt uses one
of the following method: *)
type async_method =
| Async_none
(** System calls are made synchronously, and may block the
entire program. *)
| Async_detach
(** System calls are made in another system thread, thus without
blocking other Lwt threads. The drawback is that it may
degrade performance in some cases.
This is the default. *)
| Async_switch
(** System calls are made in the main thread, and if one blocks
the execution continue in another system thread. This method
is the most efficient, also you will get better performance
if you force all threads to run on the same cpu. On linux
this can be done by using the command [taskset].
Note that this method is still experimental. *)

Of the three methods, Async_switch, AFAICT, was only ever working on Linux, but might be broken now (#184). Since it is non-portable, marked as experimental, probably broken, and unsupported, I think we should deprecate it and eventually remove it.

Of the remaining two methods, Async_none and Async_detach, Async_detach is the reason why someone would want to use Lwt at all, over Unix. In case we bind a system call that is not available in blocking form in Unix, we can expose both synchronous and asynchronous bindings from Lwt. So, we should also remove Async_none, and thus the whole async_method type.

IIRC, setting the async method explicitly is basically not used in opam. I would have to look again to see what the exact impact is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions