4
lorentz
268d

Thread-local static variables in expression scope are so cool. You can initialize them with heap-bound datastructures, they retain their value like statics but you don't need a mutex to interact with them, and you can define them with macros that are called in expression scope. The perfect building block for unobtrusive caching.

I used to really hate statics in C++ when I was starting out with programming because I felt that they introduced unexpected persistent state, but I guess I have grown to appreciate locality a lot more since.

Comments
  • 1
    Are c++ statics thread local by default?
  • 2
    @Lensflare In C++ thread_local is a storage class that syntactically replaces and semantically implies static. In Rust, thread_,local is a macro that accepts a sequence of static variable declarations.
  • 2
    @Lensflare When I last actively used C++ I didn't know about concurrency so I had to look this up right now.
  • 0
    @dfox mentions seem to be broken again. I didn’t get the mention notifications from the comments above.
  • 0
    I was depressed for months after losing a lot of money trading cryptocurrency online on elitefx. I am happy today because I was able to recover my USDT from those who stole from me through the help of [HACKRECOVERY {at} YANDEX {dot} RU ]. Their support service was easy to work with and they did their job in less than two weeks without too many excuses and stories. Will advise you to reach their support service agent on the aforementioned address if you are having a similar issue.
Add Comment