Glib::Threads:Private

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Glib::Threads:Private

John Emmas-2
I realise it's a deprecated interface but can anyone explain what
Glib::Threads:Private<SomeObject> does?

Does it guarantee that 'SomeObject' can only be accessed by code running
in a particular thread?  And if so, does it do that by creating a
specific thread for the object - or does it use whichever thread was
running when Glib::Threads:Private got called?  Hope that makes sense....

John
_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Glib::Threads:Private

Paul Davis


On Wed, Feb 20, 2019 at 1:17 AM John Emmas <[hidden email]> wrote:
I realise it's a deprecated interface but can anyone explain what
Glib::Threads:Private<SomeObject> does?

Does it guarantee that 'SomeObject' can only be accessed by code running
in a particular thread?  And if so, does it do that by creating a
specific thread for the object - or does it use whichever thread was
running when Glib::Threads:Private got called?  Hope that makes sense....

It means that each thread that accesses the variable sees a distinct or "thread-local" version of it.
The language runtime creates memory for thread-local storage at program startup, and each thread has its own section (inaccessible from other threads) where these "thread-local" variables are allocated.

_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: Glib::Threads:Private

John Emmas-2
On 20/02/2019 15:26, Paul Davis wrote:

On Wed, Feb 20, 2019 at 1:17 AM John Emmas <[hidden email]> wrote:
I realise it's a deprecated interface but can anyone explain what
Glib::Threads:Private<SomeObject> does?

[...]....

It means that each thread that accesses the variable sees a distinct or "thread-local" version of it.
.

Thanks Paul - so would a typical use case be for static members of a class? In normal circumstances, a static class member has the same value for all instances of the class. But maybe (in this case) 2 objects running in different threads could each have different values?

John

_______________________________________________
gtk-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-devel-list