Boost logo

Boost :

From: Alisdair Meredith (alisdair.meredith_at_[hidden])
Date: 2003-01-26 14:01:00


In view of the pending comittee meeting, and knowing those involved will
be wanting to tie down any loose ends, I'm going to ask a thread-related
question which relates as much to language support (I think) as boost
thread, but this seems to be the active place for threads/ISO at the
moment (please correct me if wrong)

I am going through our logging code again as we now have competing
requirements and more rigorous requests for thread support. Currently
our logging goes through a singleton implementation (provided by Andrei
and the Loki library, thanks Andrei) but I would like to move to what I
would describe as 'singleton-per-thread'.

The neat thing about singletons (or at least this implementation) is
that they exist for the lifetime of the process, potentially created
before main and destructed only after main has exited. I would like a
similar facility on a per-thread basis (tied to each thread's stack)
This would allow me to log from multiple threads without having to lock
the logger object, and without interspersing each threads messages
throughout the same log.

Is such an implementation possible with the current boost::thread, and
is such an implementation currently under consideration in the lagnuage
extension TR wrt thread support?

It would seem 'obvious' to me that I would want to create each logger
object in the stack of each thread, rather than as part of the parent
thread object owned by the thread creating the child-thread. I also
believe this logger example could quite easily be generalised to a whole
group of designs that want per-thread 'singletons', but the logger makes
a fairly clean example.

-- 
AlisdairM
Team Thai Kingdom

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk