$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Ryan, Paul L. (PAUL.L.RYAN_at_[hidden])
Date: 2006-10-17 11:44:08
Ion,
I don't think that quite answers my question (but maybe it does) a simple
example of what I would like to be able to do is:
void main()
{
boost::interprocess::managed_shared_memory shm;
if(shm.isInitialized()) // This functionality would be nice
{
shm.construct<int>()();
}
}
Or
void main()
{
boost::interprocess::managed_shared_memory shm;
try
{
shm.construct<int>()();
}
catch(interprocess_initialized e) // This functionality is also ok
{
}
}
Again thanks for your assistance.
Paul Ryan
SAIC - Tactical Systems
-----Original Message-----
From: igaztanaga_at_[hidden] [mailto:igaztanaga_at_[hidden]]
Sent: Tuesday, October 17, 2006 9:20 AM
To: boost_at_[hidden]; Ryan, Paul L.
Subject: Re: [interprocess] Segment existance check
Hi,
> Ion,
>
> I don't know if I'm just missing it or if this feature doesn't exist,
> but is there a feature in interprocess to check that a segment exists
> prior to attempting to find or construct a variable in that segment?
> If it doesn't exist this would be an extremely useful feature so that
> when an application goes to create an object in shared memory where
> the shared memory segment has not been created the program doesn't
> just segfault but gives the application at least a small chance of
> exiting gracefully (i.e. a thrown exception).
If you hold a reference to a managed_shared_memory the segment always
exists, since in Interprocess, the processes is detached from the segment in
the destructor of the managed_shared_memory. This is different from Shmem,
where you could call "close()". No other processes can destroy the segment
while you have a opened/created managed_shared_memory. At best, in UNIX, it
will unlink it, so new processes won't be able to find it, but old processes
attached to the segment will continue working fine.
I don't know if I have responded correctly to your question, so could you
show me an example of what do you want to achieve?
Regards,
Ion