[libxml++] Re: noncopyable class



Brad Mells wrote:

Hi Christophe:

Perhaps you can help me to better understand this noncopyable class in libxml++. If it were implemented I believe I would never need be concerned about the document integrity. But since it is not implemented I assume that I need to worry about handling asynchronous events in my program. I hope you understand that it is quite difficult for me to try to find the answer by studying the libxml2 source.


The non copyable class has nothing to do with asynchronous events. It's here only to ensure that the copy constructor of a descendant of this class cannot be called, and this verification is made at compilation because the copy constructor is private. So the implementation of noncopyable is useless because it's only the private character of the copy constructor which ensure that a descendant of noncopyable will *never* be copied by it's copy constructor.


Let's say that my cgi program parses an xml document from a file, updates the required elements and then rewrites the file. My concern is that if two events occur that execute this program simultaneously under two processes, it is possible for the second process to undo the updates written by the first (or vice versa depending on when things happen). Do I need to make system level calls in my program to ensure that this kind of thing can't happen?


If I understand correctly your problem, the only thing you need is to synchronise the accesses to your xml file. This cannot be done within libxml++, but rather by system calls. You should probably use either file locking or semaphores.

Your help is greatly appreciated. I know you are busy but you are the undeniable expert in this matter.


Please use the mailing-list of libxml++ (libxmlplusplus-general lists sourceforge net) for further discussions.

Many thanks,

Brad



Cheers

Christophe




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]