Hi Steffen,
With recent versions of NaviServer, most of the usages of bg-delivery can be replaced by "ns_writer submitfile ..." when writer-threads are in use (look for use_writerThread in [1]). The writer threads are roughly the equivalence of the bgdelivery thread, but implemented in C, not relying on select(), are lightweight in memory use and fast (using the common io-machinery of NaviServer). For the introduction to the async support in NaviServer, see section "2.3. Asynchronous Architecture" in [2].
In fact, when one is using a recent version of xotcl-core, ad_returnfile_background uses automatically the writer threads, no application code changes are needed. we use this since a while on our production systems an on openacs.org.
Actually, the only place were we are still using - and that might be the source of your interest - is the h264 streaming code. It should be actually not hard to replace there the tcl/io (e.g. replace "puts -nonewline $channel ..." by "ns_connchan write $channel ...", use "ns_connchan callback ...", etc.). This has as well the advantage that it will work without changes with tls. When one wants to copy the fd from a channel, this would defeat this purpose. So far, i had no time to look into the details to implement h264 delivery via ns_connchan.
To see ns_connchan in action, look at the WebSocket code in [3].
-g
[1] https://openacs.org/xotcl/show-object?show_methods=2&show_source=1&object=bgdelivery
[2] https://next-scripting.org/xowiki/docs/misc/naviserver-connthreadqueue/index1
[3] https://bitbucket.org/naviserver/websocket/src/c9da8e104075ed8bb9a1d3e6a244f99fd730f0fc/websocket-procs.tcl?at=default