>But what are you trying to do exactly with the locks? The only use I can >think of is that you are trying to have a multithread app with multiple >threads operating on the same file, some in read mode and some in write >mode?
That's what I would have thought as well as I am not sharing the IMapInfoFile instance between threads that instance belongs solely to the write thread, but it doesn't seem to be so. I have a multi-threaded app that some threads read from a database and put the information into a queue. The write thread takes the info from the queue and writes it to the MapInfo file. However the only state the threads share is that queue so I would think locking when accessing the queue should be enough. However it doesn't seem to work out that way. If I don't place locks around certain methods in IMapInfoFile it will crash with an I/O access error. Some of the functions that will do it so far are Open, SetMIFCoordSys, AddFieldNative, and SetFeature. If I take out a lock around these functions I get no crashes. I was thinking perhaps it has to do with how Windows juggles the IRQL when disk writes occur. I would hate to take out locks for any longer than I have to so I was trying to pin down the disk write functions to see if locking them would be enough. Thanks, Andy -----Original Message----- From: Daniel Morissette [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 05, 2005 12:12 PM To: [email protected] Subject: Re: [mitab] When does it write to disk Andrew wrote: > > I am using IMapInfoFile (I am compiling the source into my executable > not linking against the library) and I was wondering if anybody has a > list of the member functions that write to disk, that way I can > restrict my locks to specific areas vice having to lock during the > entire operation. > I don't have such a list, you'd have to look through the code to find them, or perhaps you could try putting your lock around the TABRawBinBlock::CommitToFile() method. I think all writes to the .MAP file go through that (but I could be wrong). But what are you trying to do exactly with the locks? The only use I can think of is that you are trying to have a multithread app with multiple threads operating on the same file, some in read mode and some in write mode? FYI, puting mutexes around the functions that write to the file would not be enough to be able to write to and read from the same file because the header block is only written when the file is closed for instance, and even when other blocks are written I'm not sure that all the places that refer to the new data blocks are forced to disk until you close the dataset. HTH Daniel -- ------------------------------------------------------------ Daniel Morissette [EMAIL PROTECTED] DM Solutions Group http://www.dmsolutions.ca/ ------------------------------------------------------------ Yahoo! Groups Links Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/mitab/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
