Questions tagged [boost-intrusive]

Boost Intrusive is a library presenting some intrusive containers to the world of C++. Intrusive containers are special containers that offer better performance and exception safety guarantees than non-intrusive containers (like STL containers)

The main difference between intrusive containers and non-intrusive containers is that in C++ non-intrusive containers store copies of values passed by the user (an intrusive container stores the objects themselves).

The performance benefits of intrusive containers makes them ideal as a building block to efficiently construct complex containers like multi-index containers or to design high performance code like memory allocation algorithms.

While intrusive containers were and are widely used in C, they became more and more forgotten in C++ due to the presence of the standard containers which don't support intrusive techniques. Boost.Intrusive wants to push intrusive containers usage encapsulating the implementation in STL-like interfaces.

25 questions
1
vote
1 answer

Boost Intrusive Swap

I have a class declared as class MyClass : public list_base_hook>. I also have a list declared as list global_list_MyClass. I insert 10 nodes into global_list_MyClass using a for loop. My objective is try to swap…
Jimmy
  • 153
  • 1
  • 6
1
vote
1 answer

Confusion about one element in more boost::intrusive containers

I don't quite understand how it is possible that the same elements can appear in different intrusive containers while preserving the performance and memory usage guarantees that the boost::intrusive documentation states. The documentation says…
Martin
  • 9,089
  • 11
  • 52
  • 87
1
vote
2 answers

Boost Intrusive Hashtable

Can anyone provide a simple example of how to use the Boost Intrusive Hashtable? I've tried to implement it, but I'm having little luck. I have this so far void HashTableIndex::addToIndex(Message* message) { hashtable::bucket_type…
mikez
  • 160
  • 1
  • 15
0
votes
1 answer

TSAN thread race error detected with Boost intrusive_ptr use

Below code generates a TSAN error(race condition). Is this a valid error ? or a false positive ? Object is destroyed only after ref count becomes zero(after all other thread memory operations are visible - with atomic_thread_fence) If I use a…
aKumara
  • 395
  • 1
  • 12
0
votes
1 answer

Mask information into a pointer - C++ (Boost.Intrusive)

On Boost I read about masking information into pointers to save memory (here: https://www.boost.org/doc/libs/1_72_0/doc/html/intrusive/set_multiset.html, optimize_size). How is this possible? I read somewhere that pointers only use 48 Bit, but are…
Zweistein
  • 293
  • 1
  • 4
  • 11
0
votes
2 answers

Why boost intrusive list 's push_back function requires lvalue?

I am learning intrusive list: #include #include #include struct DummyObject : public boost::intrusive::list_base_hook<>{ double price; DummyObject(const double a): price(a){ } }; using…
eight3
  • 125
  • 3
0
votes
1 answer

boost intrusive get next directly from node

Is it possible to get next node/element directly from node/element? Like so: struct Data{ boost::intrusive::list_member_hook<> node; Data* get_next(){ node.get_next() ??? } }
tower120
  • 5,007
  • 6
  • 40
  • 88
0
votes
0 answers

How to hide Boost intrusive list hook ?

In the following code: using namespace boost::intrusive; struct Data { int i; private: list_member_hook<> list_node; // How to make this work? }; using List = list< Data, member_hook< Data, list_member_hook<>, …
tower120
  • 5,007
  • 6
  • 40
  • 88
0
votes
1 answer

thread safe boost intrusive list is slow

I wrapped a boost intrusive list with mutex to make it thread safe, to be used as a producer/consumer queue. But on windows (MSVC 14) it's really slow, after profiling, 95% of time is spent idle, mainly on push() and waint_and_pop() methods. I only…
xvan
  • 4,554
  • 1
  • 22
  • 37
0
votes
0 answers

How to free memory when using boost::intrusive_ptr in C++?

I use boost::intrusive_ptr like this: void func() { boost::intrusive_ptr < MyObject > obj = new MyObject(); getStage()->addChild( obj ); } If I understand this code right - here I get a memory leak because I don't free memory which was…
JavaRunner
  • 2,455
  • 5
  • 38
  • 52
1
2