|
-
March 12th, 2012, 07:49 AM
#1
Sharing data between processes
Hello,
I have a developed an application which uses a complex data structure as data source. This data structure should exist only one time in memory. Every instance of my appliction should be able to access and change this data storage. (for e.g. a bunch of maps, lists and sets). What would be the best way to realize this? I thought about developing a Windows Service which uses boost inter- process communication? Is this doable or am I completely wrong?
Kind regards,
Michael
-
March 12th, 2012, 08:14 AM
#2
Re: Sharing data between processes
Memory-Mapped File may be an option.
Best regards,
Igor
-
March 12th, 2012, 08:30 AM
#3
Re: Sharing data between processes
Hmm, doesn't this only work for files?
Maybe I should describe a bit more detailed what I got.
Currently I have a data handler class which provides several public functions and is a singleton instance (managing several data containers). This will only work for the current process which runs the data handler instance. So my idea was to 'outsource' my datahandler with it's data containers to have one single point of data handling for all my processes. The 'processes' are any windows program - my app is a namespace extension runing in the explorer.exe process, but the already buffered should be available in 'save as...' dialogs of any applications too. So that the data doesn't need to be reloaded again and again.
-
March 12th, 2012, 12:22 PM
#4
Re: Sharing data between processes
 Originally Posted by chaos2oo2
Hmm, doesn't this only work for files?
No, MMFs can share any kind of data betweeen processes, and might be a good choice for your needs. See "Creating Named Shared Memory" at http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
 Originally Posted by MSDN Documentation
To share data, multiple processes can use memory-mapped files that the system paging file stores.
Mike
-
March 12th, 2012, 07:57 PM
#5
Re: Sharing data between processes
So my idea was to 'outsource' my datahandler with it's data containers to have one single point of data handling for all my processes.
Well, you always can do that. But this is not what they call sharing data. This is servicing data.
Best regards,
Igor
-
March 13th, 2012, 02:08 AM
#6
Re: Sharing data between processes
will it be possible to pass a pointer to an instance of an object (which will be in the shared memory) to the service method then? In case of a seperate process?
@Igor:
How is servicing data implemented?
-
March 13th, 2012, 04:00 AM
#7
Re: Sharing data between processes
Pointers are valid only in context of an origin process. Passing pointers across process bounds are meaningless and must be avoided.
Servicing data means some API or protocol for data exchange. It's up to you how you implement it, but the main point is that there is only single entity that performs physical data read and write with some persistent storage.
Best regards,
Igor
-
March 13th, 2012, 05:21 AM
#8
Re: Sharing data between processes
so as far as I see there is no easy way, I don't have the time to implement the whole data exchange on my own. What must be passed are lists of instances from my data handler.
A process queries the data handler (by passing a pointer to an parent instance object) and receives a set of instance pointers. That's how it is implemented right now...using a singleton.
-
March 13th, 2012, 06:31 AM
#9
Re: Sharing data between processes
 Originally Posted by chaos2oo2
Currently I have a data handler class which provides several public functions and is a singleton instance (managing several data containers). This will only work for the current process which runs the data handler instance. So my idea was to 'outsource' my datahandler with it's data containers to have one single point of data handling for all my processes. The 'processes' are any windows program - my app is a namespace extension runing in the explorer.exe process, but the already buffered should be available in 'save as...' dialogs of any applications too. So that the data doesn't need to be reloaded again and again.
That's a typical issue for a software architect which is sleeping with the GoF's little red book under the pillow and dreaming singleton (anti-)pattern with no clue about the given OS IPC (InterProcess Communications). 
So, please let me google for you: Windows InterProcess Communications
-
March 15th, 2012, 08:36 PM
#10
Re: Sharing data between processes
I have tried different methods of sharing data between processes and found that good old named pipes work best. All other methods (such as shared memory, mapped files) do not work in Vista/7 because of their tight security. With the named pipes though, you need to use proper security descriptor in order to work in Vista/7.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|