Re: [AD] Working on ex_threads, d3d_display_format.cpp, tls.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


 

It wouldn’t hurt to create an aintern_tls.h. As for tls_get returning NULL, you’d have to return an error to the user (eg return false or NULL, not sure the specifics.) But perhaps it would be better to use a mutex here. There’s no real reason this needs to be in TLS.

 

From: Edgar Reynaldo
Sent: August 21, 2016 4:07 PM
To: Allegro Developers
Subject: [AD] Working on ex_threads, d3d_display_format.cpp, tls.c

 

Hello fellas,

 

ex_threads crashes with the D3D driver due to multiple threads accessing

the same ALLEGRO_EXTRA_DISPLAY_SETTINGS list at the same time. I am

working on a patch for this.

 

I'd like to add the display format list to thread local storage to avoid

the multiple access problem. This is not hard.

 

I've also altered d3d_display_formats.cpp to use the thread local

storage state as well.

 

I have a few questions though.

 

1. What is the proper way to access the tls_get function and the

thread_local_state? There is no public api available to access tls_get,

nor is there a private one. In tls.c, getter and setter functions are

used to interact with the thread_local_state. Is this the preferred way

to do this? Alternatively, there is the tls_get function, which seems

the most appropriate to use in this case (for d3d_display_formats.cpp).

It is accessible through one of three different headers, (tls_dll.inc ,

tls_pthread.inc , or tls_native.inc).

 

2. Should there be a public (at least public to the library) header

available for the tls_get function? I propose moving the includes for

tls_dll.inc, tls_pthread.inc, and tls_native.inc into their own tls

header. Perhaps into tls.h, or into aintern_tls.h?

 

I have made a preliminary patch for this, available as an attachment.

It's not complete though. There are some specific things that need to be

completed first, such as solving #1 (how to import the tls_get function

into d3d_display_formats.cpp), and what to do when tls_get returns NULL.

 

This was first discussed on the a.cc forum, but I haven't had time to do

much until recently. See the associated thread here :

https://www.allegro.cc/forums/thread/616214/1021962#target

 

Let me know what you want me to do.

 

Thanks,

Edgar

 

 



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/