std::multiset functionality support in boost interprocess headers
Hi all,
I see multiset is not present in boost interprocess, so I tried to use a
"set" with a customized comparator to achieve multiset functionality.
sample code:
struct set_comparator
{
bool operator()(const int& a, const int& b) const
{
return a < b; // if change a <= b then seeing an errror
}
};
bip::shared_memory_object::remove("SHM");
bip::managed_shared_memory segment(bip::open_or_create, "SHM",
2047*1024*1024);
typedef bip::allocator , long int, long unsigned int, 0> >]: Assertion `( p == this->end() ||
!this->comp()(*p, value) )' failed. "Need input on this or is this expected behaviour as per boost??"
--
Regards,
Murali Kishore
El 09/09/2024 a las 15:18, Murali Kishore via Boost escribió:
Hi all,
I see multiset is not present in boost interprocess, so I tried to use a "set" with a customized comparator to achieve multiset functionality.
You can use any Boost.Container container with Boost.Interprocess, including multiset. Boost.Interprocess own container aliases will be deprecated soon, since they only forward to Boost.Container. I'll maintain those container header inside Interprocess for backwards compatibility for several Boost releases but in the end they will be removed. Best, Ion
Thanks Ion. I have tried the following sample, I see one issue that "find"
is failing in the following sample.
#include
El 09/09/2024 a las 15:18, Murali Kishore via Boost escribió:
Hi all,
I see multiset is not present in boost interprocess, so I tried to use a "set" with a customized comparator to achieve multiset functionality.
You can use any Boost.Container container with Boost.Interprocess, including multiset.
Boost.Interprocess own container aliases will be deprecated soon, since they only forward to Boost.Container. I'll maintain those container header inside Interprocess for backwards compatibility for several Boost releases but in the end they will be removed.
Best,
Ion
-- Regards, Murali Kishore
El 28/09/2024 a las 9:49, Murali Kishore via Boost escribió:
[...]
// Define the unordered_map type typedef boost::unordered_map
, std::less , MapAllocator> timer_instance_map_t;
You have to use std::equal_to
Thanks, it worked. On Sat, Sep 28, 2024 at 2:36 PM Joaquin M López Muñoz via Boost < boost@lists.boost.org> wrote:
El 28/09/2024 a las 9:49, Murali Kishore via Boost escribió:
[...]
// Define the unordered_map type typedef boost::unordered_map
, std::less , MapAllocator> timer_instance_map_t; You have to use std::equal_to
rather than std::less . Please try and let us know if that solves your issue. Joaquin M Lopez Munoz
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Regards, Murali Kishore
Hi,
I am observing that the first 4 bytes are changed to zero, let me know what
is the reason for this.
before insert:
(gdb) p instance
$1 = (ngp::timer_manager::timer_instance_t &) @0x7fffb610e118: {padding =
*1919*, id = 2, api_id = 1, next = {__d = {
__r = 98595033760891}}, period = {__r = 20000}, max_iterations = -1,
running = false, user_data = 0x0,
target_identifier = 0,
startAddr = 0x5555555c22cb
Thanks, it worked.
On Sat, Sep 28, 2024 at 2:36 PM Joaquin M López Muñoz via Boost < boost@lists.boost.org> wrote:
El 28/09/2024 a las 9:49, Murali Kishore via Boost escribió:
[...]
// Define the unordered_map type typedef boost::unordered_map
, std::less , MapAllocator> timer_instance_map_t; You have to use std::equal_to
rather than std::less . Please try and let us know if that solves your issue. Joaquin M Lopez Munoz
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Regards, Murali Kishore
-- Regards, Murali Kishore
El 30/09/2024 a las 18:44, Murali Kishore via Boost escribió:
Hi,
I am observing that the first 4 bytes are changed to zero, let me know what is the reason for this.
You need to provide us with a fully compilable example, otherwise it's not easy to deduce what's happenning in your code. Apart from that, you are storing raw pointers inside timer_instance_t, and that is not going to work between processes. See: https://www.boost.org/doc/libs/1_86_0/doc/html/interprocess/sharedmemorybetw... Best, Ion
You still leak instances, because you do a redundant `construct<>` call before emplacing. Always simplify:
[Live On Coliru](https://coliru.stacked-crooked.com/a/4d1a689fc03f3910)
```c++
#include
Thanks, it worked.
On Sat, Sep 28, 2024 at 2:36 PM Joaquin M López Muñoz via Boost < boost@lists.boost.org> wrote:
El 28/09/2024 a las 9:49, Murali Kishore via Boost escribió:
[...]
// Define the unordered_map type typedef boost::unordered_map
, std::less , MapAllocator> timer_instance_map_t; You have to use std::equal_to
rather than std::less . Please try and let us know if that solves your issue. Joaquin M Lopez Munoz
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Regards, Murali Kishore
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (4)
-
Ion Gaztañaga
-
Joaquin M López Muñoz
-
Murali Kishore
-
Seth