Threaded structure fields!
Posted: Thu Oct 22, 2009 11:35 am
Hi,
this is a coding question combined with a feature request (in the event that no one can see an easy way to solve my problem!
)
At the moment I am battling with a problem which, if allowed to use api, would be easy to solve via a TLS (Thread Local Storage) index. However, I am confined to using 100% crossplatform code in this instance and would like to avoid conditional compilation to employ the equivalent of such indexes for Linux etc.
My problem would additionally be solved if it would be possible to nominate a field within a structure as being threaded! (And this would comprise my feature request!)
At this minute I see no way of resolving my problem using the Threaded variables introduced in PB 4.4 (as great and as useful as these are). Here's a brief outline of the situation :
I cannot simply create the EC handles as threaded variables because the handles themselves would not be preserved across threads and there of course could be many such handles in use at any given time.
In terms of being crossplatform, the only 'solutions' (untested) I can think of are way too complex for my liking.
With these kind of things though I normally overlook the simplest solutions!
Thought I'd therefore post this in the form of a coding question in the hope that someone can see what I cannot right now?
Thanks in advance for any suggestions.
Stephen.
this is a coding question combined with a feature request (in the event that no one can see an easy way to solve my problem!

At the moment I am battling with a problem which, if allowed to use api, would be easy to solve via a TLS (Thread Local Storage) index. However, I am confined to using 100% crossplatform code in this instance and would like to avoid conditional compilation to employ the equivalent of such indexes for Linux etc.
My problem would additionally be solved if it would be possible to nominate a field within a structure as being threaded! (And this would comprise my feature request!)

At this minute I see no way of resolving my problem using the Threaded variables introduced in PB 4.4 (as great and as useful as these are). Here's a brief outline of the situation :
- User calls my library to map a certain file into memory ... for his troubles, the user (client app) receives what I have termed an EC handle (similar to a device context) used to identify this mapping. Of course, this handle is a pointer to an internal structure.
- User may map as many files as he wishes and for each he receives a unique EC handle. There can thus be many valid EC handles in operation at once.
- Against each EC handle, the user can create multiple-threads. Each thread must have access to the underlying EC handle but also requires additional fields unique to the thread of execution in question.
I cannot simply create the EC handles as threaded variables because the handles themselves would not be preserved across threads and there of course could be many such handles in use at any given time.
In terms of being crossplatform, the only 'solutions' (untested) I can think of are way too complex for my liking.
With these kind of things though I normally overlook the simplest solutions!

Thanks in advance for any suggestions.
Stephen.