我想知道是否有人对在线程或进程之间共享数据(通过共享内存段)有一些想法或反馈。我正在考虑跨线程/进程传递一些所有权对象(通过管道/同步队列)。唯一可以访问数据的线程是拥有该对象(或内存区域)所有权的线程。如果一个线程想要访问其他地方拥有的对象,那么它会出现异常或阻塞。知道如何干净地实现这个协议吗?
I would like to know if someone has some idea or feedback about sharing data between thread or processes ( through a shared memory segment ). I was thinking about passing across the threads/process some ownership object ( through a pipe/ synchronized queue ). The only thread that can access data are the one owning the ownership of that object( or memory area ). If one thread wants to access an object that is own elsewhere then it gets an exception or it blocks . Any idea how to cleanly implement this protocol ?
发布评论
评论(1)
如果您可以扩展可能的语言以包含 C++,Boost.Interprocess< /a> 支持便携式共享内存。
您应该能够通过将其与 Boost.Thread 中的条件变量。
If you can extend your possible languages to include C++, Boost.Interprocess supports portable shared memory.
You should be able to implement the blocking you describe by combining this with condition variable in Boost.Thread.