NDC stack of parent thread visible to child thread??

View: New views
3 Messages — Rating Filter:   Alert me  

NDC stack of parent thread visible to child thread??

by deepak singh-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
  Is there any way through which I can inherit the NDC stack to the child thread?
  I have a parent thread running and create a child thread, I want the NDC stack of the parentthread
  should also be applied to the child thread.
  Please let me know if we have anyway to do that?
Thnaks
Deepak

Re: NDC stack of parent thread visible to child thread??

by Assaf Lavie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1. I find it very useful to implement a simple stack class that uses RAII to manage the NDC stack. In fact, I find it odd that log4cxx doesn't come with one built-in..
2. Using a stack such as this it's really not a problem to pass a copy to another thread.

On Tue, Jun 23, 2009 at 1:32 PM, deepak singh <deepak.iitg@...> wrote:
Hi,
  Is there any way through which I can inherit the NDC stack to the child thread?
  I have a parent thread running and create a child thread, I want the NDC stack of the parentthread
  should also be applied to the child thread.
  Please let me know if we have anyway to do that?
Thnaks
Deepak


Re: NDC stack of parent thread visible to child thread??

by Jacob L. Anawalt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-06-23 23:00, Assaf Lavie wrote:
> 1. I find it very useful to implement a simple stack class that uses RAII to
> manage the NDC stack. In fact, I find it odd that log4cxx doesn't come with
> one built-in..2.

I just use the NDC class and "push" via the constructor. It "pops" when the
object is deconstructed [0]. This fits my expectations of RAII[1].

[0] http://wiki.apache.org/logging-log4cxx/NestedDiagnosticContexts
[1] http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.18

--
Jacob Anawalt
Gecko Software, Inc.
janawalt@...
435-752-8026