My project involves a plugin, and a GUI for said plugin which is isolated into a separate process. The data I'm sharing may be updated by the GUI, and when it is, it should be processed by the plugin.
To do this, I'm considering putting this in my shared-memory block:
std::atomic_bool event_flag;
// insert mutex...
some_data_struct data;
In essence, the GUI does the following when it wants to change the data:
// acquire mutex
// write data...
// release mutex
event_flag = true;
event_flag.notify_one();
Then the plugin does the following:
event_flag.wait(true);
event_flag = false;
// acquire mutex
// read data...
// release mutex
The C++ standard never specified how C++ code interacts with shared memory and processes, so much of this is implementation-defined.
However, it seems that implementations are not cross-process:
There is a proposal for process management , but that hasn't gone too far, given that the C++ standard doesn't have a concept of "processes".
I will edit this answer if such behaviour is eventually specified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.