LibUV Final Grant Report by Paul Evans
Thu, 19-Aug-2021 by
Moritz Lenz
edit post
Paul "LeoNerd" Evans has submitted his final grant report for the LibUV grant.
The Grants Committee will vote on its completion and payment. If you have feedback or question on its completion, please comment here.
---
The latest release of UV version 2.000 indicates that this project is
now fundamentally done. The CPAN version of UV, the libuv binding
module, is now sufficiently complete and useable, to allow event
systems and other similar modules to make use of the abstractions
provided by libuv.
It's unlikely that most programs would choose to operate directly with
UV itself, but rather via some higher-level event system. There are UV
adapter modules for IO::Async (IO::Async::Loop::UV), Mojo
(Mojo::Reactor::UV), and Future::IO (Future::IO::Impl::UV) at least.
The UV module certainly wraps much of what libuv has to offer, but
there are still some parts missing. libuv can watch filesystems for
changes of files, and provides asynchronous filesystem access access
functions - both of these are currently missing from the Perl binding.
Threadpools are an entire concept that doesn't map very well to the
Perl language, so they are absent too. Finally, libuv lists an entire
category of "miscellaneous functions", most of which are already
available independently in Perl, so there seems little point to
wrapping those provided by libuv.
Finally, we should take note of one thing that doesn't work - the
UV::TCP->open and UV::UDP->open functions when running on Windows. The
upshot here is that you cannot create TCP or UDP sockets in your
application independently of libuv and then hand them over to be
handled by the library; this is not permitted. This is because on
Windows, there are fundamentally two different kinds of sockets that
require two different sets of API to access them - ones using
WSA_FLAG_OVERLAPPED, and ones not. libuv needs that flag in order to
perform event-based IO on sockets, and so it won't work with sockets
created without it - which is the usual kind that most other modules,
and perl itself, will create. This means that on Windows, the only
sockets you can use with the UV module are ones created by UV itself -
such as by asking it to connect out to servers, or listen and accept
incoming connections. Fortunately, this is sufficient for the vast
majority of applications.
While approaching the end of this project, I found that there is a
shortage of Win32 experts around Perl. It was difficult to to get some
expert opinion on the Windows-specific testing failures that were
holding back a complete release of this module, as it was unclear
whether the things being tested were supposed to be working or not.
I would like to finish up by saying thanks to The Perl Foundation for
funding me to complete this project.
Comments (0)