Re: [Boost-bugs] [Boost C++ Libraries] #9792: named_mutex is not process Persistence by default in windows

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9792: named_mutex is not process Persistence by default in windows
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-19 10:07:53


#9792: named_mutex is not process Persistence by default in windows
-------------------------------+--------------------------
  Reporter: huyuguang@… | Owner: igaztanaga
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: interprocess
   Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------

Comment (by huyuguang@…):

 I am so sorry, the named_mutex is kernel/filesystem persistence and the
 interprocess_mutex is process persistence.

 So how can I get a named mutex which is process persistence?

 What I need is I need to know if current process is the first process so
 that it can create a managed_shared_memory. Since the
 managed_shared_memory is kernel/filesystem persistence, if the processes
 crash, the file would still exist in folder.
 So I want to use a process persistence named mutex to avoid this, the code
 looks like:
 bool init() {
         mutex1 = create_mutex("mutex1");
         if (!mutex1) {
                 mutex1 = open_mutex("mutex1");
                 if (!mutex1)
                         return false;
                 managed_shared_memory segment(open_only,"mem1");
         } else {
                 shared_memory_object::remove("mem1");
                 managed_shared_memory segment(create_only,"mem1");
         }
         return true;
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9792#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC