[Documentation] [TitleIndex] [WordIndex

  Show EOL distros: 

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

ros_realtime: allocators | lockfree | rosatomic | rosrt

Package Summary

The lockfree package contains lock-free data structures for use in multithreaded programming. These kinds of data structures are generally not as easy to use as single-threaded equivalents, and are not always faster. If you don't know you need to use one, try another structure with a lock around it first.

The lockfree package contains lock-free data structures generally meant to be used in realtime or high-performance multithreaded systems.

Currently lockfree contains 2 data structures, FreeList and ObjectPool.

FreeList

The FreeList class provides a fixed number of fixed-size blocks that you can allocate and free from multiple threads. FreeList is lock-free but not wait-free.

Example

   1 // Create a free list with 100 128-byte blocks
   2 FreeList free_list(128, 100);
   3 void* mem = free_list.allocate();
   4 
   5 if (mem)
   6 {
   7   ...
   8 
   9   free_list.free(mem);
  10 }

ObjectPool<T>

While the FreeList class simply provides allocation of specific-sized blocks of memory, the ObjectPool class builds on top of that to provide allocation of specific object types, initialized using a template object. It also allows you to allocate either boost::shared_ptrs or bare pointers, depending on your needs. ObjectPool is lock-free but not wait-free.

Example

   1 struct Foo
   2 {
   3   std::vector<uint32_t> bar;
   4 };
   5 
   6 // Create a template object.  All objects in the pool will start initialized to this value.
   7 // In realtime systems, for example, this lets you preallocate any vectors/strings/etc.
   8 Foo template_object;
   9 template_object.bar.resize(100);
  10 
  11 // Construct a pool of 5 objects
  12 ObjectPool<Foo> pool(5, template_object);
  13 
  14 boost::shared_ptr<Foo> inst1 = pool.allocate();
  15 if (inst1)
  16 {
  17   ...
  18 }
  19 
  20 Foo* inst2 = pool.allocateBare();
  21 if (inst2)
  22 {
  23   ...
  24   pool.freeBare(inst2);
  25 }


2024-12-07 14:54