|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-09-04 17:46:59
Hi Roland,
--- Roland Schwarz <roland.schwarz_at_[hidden]> wrote:
> Yes it apparently fixes the problem, but as I can currently see, it
> defeats the original purpose of the single call to WSAStartup. It
> seems not to be necessary in this case. What the code is trying to
> achive is kind of a call_once, as I can currently see.
Yes, although the problem in this case is not so much calling
WSAStartup once, but ensuring that WSACleanup is called after all
demuxer objects have been destroyed (including global ones).
> Why not simply use boost threads once function instead?
Does it address the issue of order of cleanup with respect to globals?
> I also discovered another issue:
> The number of demuxers is implicitely limited by available TSS slots.
> This also is an issue that long ago has been succesfully solved in
> the threading library.
Yes, although the demuxer's use of tss is to keep track of whether the
current thread is "in" the demuxer. The problem I had with the boost
tss when I first investigated it a couple of years ago was that it
seemed to involve storing an object in tss, when all I really wanted
was a thread-specific boolean flag (and I had no need for cleanup).
However I can think of an implementation that would only use one tss
slot for all demuxers, at a small runtime cost in unusual use cases. I
will investigate doing that for 0.3.4.
> A final question is poping up:
> Why not using the boost threading? Or is this planned for future?
It doesn't use boost threads internally so that it can keep the library
header-file only, i.e. to avoid adding a dependency on any non-system
DLLs or libraries. But if a future boost threads release was
header-file-only for the most commonly used bits (threads, mutex,
condition)... ;)
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk