简体   繁体   English

列出Boost命名的托管共享内存的名称

[英]List names of boost named managed shared memory

I am using boost managed_shared_memory. 我正在使用boostmanaged_shared_memory。 And I am creating by name. 我是按名字创建的。

Eg: managed_shared_memory Segment(open_only, OneName); 例如:managed_shared_memory Segment(open_only,OneName);

And inside in an own segment I can list all existing objects (created by Segment::construct). 在自己的段中,我可以列出所有现有对象(由Segment :: construct创建)。

But is it possible to get a list of existing segments? 但是可以获取现有细分的列表吗? (Eg to avoid double naming...) (例如,避免重复命名...)

Such like (Pseudo): 如(伪):

boost::interprocess::list_existing_segments 

If it is possible, please explain. 如果可能,请解释。 If not, be so kind to confirm. 如果没有,请善待确认。

Greeting Earlybite 问候早咬人

But is it possible to get a list of existing segments? 但是可以获取现有细分的列表吗?

Given enough privileges, probably yes. 如果有足够的特权,也许可以。 However, that's not where Boost focuses (use tools like Process Explorer to inspect system details; on linux, ls /dev/shm usually helps). 但是,Boost并不专注于此(使用Process Explorer等工具检查系统详细信息;在Linux上, ls /dev/shm通常会有所帮助)。 ¹ ¹

(Eg to avoid double naming...) (例如,避免重复命名...)

That's not viable, as at this point you'd only get a race. 那是不可行的,因为此时您只能参加比赛。 As soon as you "established" that a given name is not in use yet, it might simultaneously be created by one of the many other processes in the system. 一旦“确定”尚未使用给定名称,该名称可能同时由系统中许多其他进程之一创建。 So the result of your check is useless. 因此,检查结果毫无用处。

You cannot hedge this by interprocess synchronization, because (catch-22) the same problem applies to the synchronization object used for that. 您不能通过进程间同步来对冲它,因为(catch-22)相同的问题也适用于用于同步的对象。

In short: You can only try the creation and notice that it failed. 简而言之:您只能尝试创建并注意创建失败。


¹ Likewise, Boost doesn't focus on lowlevel hardware access, instead abstracting a higher level interface that's portable ¹同样,Boost并不专注于底层硬件访问,而是抽象了可移植的高层接口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM