Thread: Is serialization needed, if portability isn't important?

  1. #16
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Now is just as good a time as any to mention that I always reach for "sqlite" by default when writing code for others and I've never had a wiggle of a performance issue due to that aspect of communication.

    Soma

  2. #17
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    If the different processes are considered to be all logically part of the same program (i.e. the fact that there are multiple processes is an "implementation detail"), and the modules are always built together and deployed together, then I would share structures directly, at will. This is especially the case if the processes are direct fork()'s of each other -- share away!

    If the processes are more like clients/servers, peers, SOA entry points, or otherwise, then I would transport data with extreme paranoia (as if they could all potentially be implemented with alien technology).

    EDIT: Obviously there are serious issues if the shared data contains pointers which are actually dereferenced.
    Last edited by brewbuck; 04-13-2012 at 01:04 PM.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #18
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by brewbuck View Post
    If the different processes are considered to be all logically part of the same program (i.e. the fact that there are multiple processes is an "implementation detail"), and the modules are always built together and deployed together, then I would share structures directly, at will. This is especially the case if the processes are direct fork()'s of each other -- share away!

    If the processes are more like clients/servers, peers, SOA entry points, or otherwise, then I would transport data with extreme paranoia (as if they could all potentially be implemented with alien technology).
    I don't think it'll matter in this case;
    as the file I'll be mapping to virtual memory will already contain the data (which will be mutable, to an extent, by one of the processes).
    So, the alien tech paranoia would have to exist, as the data could be created by an alien.
    I'm trying to reduce that to the point that there would be no issues.

    EDIT: Obviously there are serious issues if the shared data contains pointers which are actually dereferenced.
    It wouldn't.

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    You might also want to look into Boost.Interprocess. Not only does it provide nice C++ abstractions around shared memory, it also has some container classes that you can place into such memory.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Serialization
    By SevenThunders in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2008, 03:12 AM
  2. Replies: 3
    Last Post: 06-12-2007, 11:21 AM
  3. Serialization yay!
    By Shamino in forum C++ Programming
    Replies: 11
    Last Post: 06-10-2007, 05:53 PM
  4. Serialization
    By Asagohan in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2005, 10:57 PM
  5. Program Portability (code portability)
    By Perica in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2002, 10:03 AM