I have a process that makes an http get request to some API every single second. This process then does some sort of work with the JSON string that is returned from the request. At the same time, I want to pass this JSON string to another process to do something else.
A key point is that I want to keep appending each new JSON string to the end of an array so that all the JSON strings are saved in memory for the duration of the program.
I'm looking into using pipes or mmap to share the JSON strings as these seem to be the fastest ways I know of. However, it seems like pipes will do more work than necessary because I will have to send the strings which seems unnecessary since they are already in memory.
I thought that mmap would be able to avoid this problem if I could just map the array to both processes. I don't want the strings written to a real file on disk, so I would have to use an anonymous mapping, but it seems that anonymous mappings create a region that is zeroed and then I will have to copy my array into the memory mapped region to share the data. This seems like unnecessary work too because I'm duplicating memory.
Is there a way that I can just give the 2nd process access to the array of strings with no duplication of the strings or copying? I can't use threads even though threads can share the memory easily because the process making the REST requests will be a C++ program while the 2nd process will be a Python program.