On 10/4/07, Siva Chandra <siv...@ya...> wrote:
> Hello all,
snip!
> This array A can be accessed by two different threads
> simultaneously - one thread could be reading a[5], and
> another writing a[5]! How to protect my array from
> such read/write conflicts? I am looking for a solution
> which enables a user of the array class not to bother
> about such conflicts. Is such a thing possible? If
> yes, what is it?
I have no idea, really, however, I do know that it was either the
Boost C++ Libraries or the STL which gives you smart pointers, which
automatically deallocate their memory when there are no more
references to them in scope. I think it could be possible to
implement a similar technique to memory locking to prevent thread
collisions. However, I've never done anything like that in C++, and
am just going out on a limb here. That's the sort of approach I'd
take assuming that it's of the utmost importance that the user of the
class need not pay any attention to thread locking/unlocking and
rubbish of that sort.
--
Registered Linux Addict #431495
If You Know What's Good For You, You'll Install Linux
John 3:16!
|