Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #120702

Re: thread_local question...

From jseigh <jseigh_es00@xemaps.com>
Newsgroups comp.lang.c++
Subject Re: thread_local question...
Date 2024-10-11 09:50 -0400
Organization A noiseless patient Spider
Message-ID <vebael$3make$1@dont-email.me> (permalink)
References <ve7cj8$2vun0$1@dont-email.me> <ve8f6l$34vt2$1@dont-email.me> <ve98fe$392tv$2@dont-email.me>

Show all headers | View raw


On 10/10/24 15:04, Chris M. Thomasson wrote:
> On 10/10/2024 4:52 AM, jseigh wrote:
>> On 10/9/24 22:02, Chris M. Thomasson wrote:
>>> How can I get access to self in my ct_foo() function below? Am I 
>>> misusing thread_local here? I want self to be able to be accessible 
>>> from any function that my ct_thread() function calls. It feels like I 
>>> am doing something wrong here. However, I am getting correct ctor's 
>>> and dtor's, I am not sure how to access self from ct_foo() called 
>>> from ct_thread()?
>>>
>>
>> std::thread::id id = std::this_thread::get_id();
>>
>> C tss uses a thread local array I think but I don't know
>> it gets notification on individual thread exits so it
>> can run the dtor.  C++ has a cvar notify all on thread
>> exits.
>>
>> I have a different hack which I won't get around to
>> until I need it.
> 
> I still don't know how C++ calls dtors wrt per-thread objects via 
> thread_local. My hack would be to use tss_create and be done with it.
> 

Ok, it looks like they are using libc atexit function (stdlib.h) to
invoke tls cleanup on thread exit.

Joe Seigh

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-09 19:02 -0700
  Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-09 19:08 -0700
  Re: thread_local question... Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-10-09 19:33 -0700
    Re: thread_local question... Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-10-09 19:40 -0700
      Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-09 20:08 -0700
    Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-09 20:19 -0700
  Re: thread_local question... jseigh <jseigh_es00@xemaps.com> - 2024-10-10 07:52 -0400
    Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-10 12:04 -0700
      Re: thread_local question... wij <wyniijj5@gmail.com> - 2024-10-11 03:20 +0800
        Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-20 19:12 -0700
          Re: thread_local question... wij <wyniijj5@gmail.com> - 2024-10-21 19:06 +0800
            Re: thread_local question... wij <wyniijj5@gmail.com> - 2024-10-21 19:20 +0800
      Re: thread_local question... jseigh <jseigh_es00@xemaps.com> - 2024-10-10 15:57 -0400
        Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-11 13:36 -0700
      Re: thread_local question... jseigh <jseigh_es00@xemaps.com> - 2024-10-11 09:50 -0400
        Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-11 12:21 -0700
          Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-11 22:53 -0700
            Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-11 22:56 -0700
        Re: thread_local question... jseigh <jseigh_es00@xemaps.com> - 2024-10-11 17:05 -0400
          Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-12 13:44 -0700
            Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-12 13:46 -0700
  Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-12 13:29 -0700
    Re: thread_local question... "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-12 13:43 -0700

csiph-web