File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileChannel#map for IPC?

 
James Kirk
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I need to pass masses of data between two processes. Apart from sockets etc, using mmap is a standard approach for native programmes. Java FileChannel supports map, but there it reads:
"Read/write: Changes made to the resulting buffer will eventually be propagated to the file; they may or may not be made visible to other programs that have mapped the same file."
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#map(java.nio.channels.FileChannel.MapMode,%20long,%20long)

So the FileChannel#map is not guaranteed to work for IPC? Has someone here successfully used it anyway?

Many TIA,
-- JK
 
Stephan van Hulst
Bartender
Pie
Posts: 4826
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I haven't really used memory mapped I/O so far, so I can't be sure, but maybe some of the methods of MappedByteBuffer can help you out.

If not, and this type of performance is really what you want, maybe it's best to write native code that handles IPC, and then use JNA to invoke these native methods.
 
James Kirk
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Well, I haven't really used memory mapped I/O so far, so I can't be sure, but maybe some of the methods of MappedByteBuffer can help you out.

If not, and this type of performance is really what you want, maybe it's best to write native code that handles IPC, and then use JNA to invoke these native methods.


The method I mentioned above creates the MappedByteBuffer. A MappedByteBuffer alone can not be used for IPC, thus the well known workaround to map a shared file.

Cheers,
JK
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic