Is there a way to use local stream variables when using ACE?

I use ACE streams and each stream must have its own int member. Is it possible?

+4
source share
5 answers

ACE calls this "specific storage". Check this out: ACE_TSS . What about everything that I know about this, sorry, there can be no more help.

The Wikipedia page for streaming local storage says there is a way for pthreads to do this too.

+2
source

Its platform is specific. Windows, for example, you should use __declspec( thread ) . The compiler will use the TLS API (TlsAlloc, TlsFree and friends), and on Win32 you should always use FLS (Fiber Local Storage) instead of TLS, but the TLS API silently redirects you to FLS in any modern version of Win32.

0
source

Yes. You can use the ACS_TSS<type> template, which is designed for "storage with a specific stream" (i.e., local stream variables).

See the docs on ACE_TSS for more details .

0
source

GCC directly supports TLS for some purposes . You can use the __thread keyword for GCC to define local thread variables (must be static or global).

libACE itself has a built-in stream-local material, you can check the documentation and see a sample code .

0
source

Unable to set ACE_TSS to the initial value for all threads; You can easily set the initial value immediately after entering your stream function.

0
source

Source: https://habr.com/ru/post/1303729/


All Articles