Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CObArray

Posted on 2006-04-25
2
Medium Priority
?
241 Views
Last Modified: 2013-11-20
I have a CObArray that I'm access from 2 different threads, one thread is suppose to be updating it and the other one only reads from it.  Is there a way to change data in it.  As of right now, I'm pulling to object out and updating the object.  I will then use RemoveAt and InsertAt to update the object in the array.  The problem is, if I try to read the item while it has been removed and hasn't been reinserted yet I have nothing to read.
0
Comment
Question by:docieb
  • 2
2 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 16536674
Hi docieb,
> The problem is, if I try to read the item while it has been removed
> and hasn't been reinserted yet I have nothing to read.
You need to add syncrhonization logic to your code, so that the read and write does't occur at the same time.

David Maisonave (Axter)
Cheers!
0
 
LVL 30

Accepted Solution

by:
Axter earned 1000 total points
ID: 16536694
You could accomplish this automatically by using one of the following synchronized smart pointers:

http://code.axter.com/sync_ptr.h  (Simple version)

http://axter.com/smartptr  (More complex policy base smart pointer)

The more complex version would require you to specify the synchronization smart pointer policy.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question