content
listlengths
1
171
tag
dict
[ { "data": "Indirect Iterator\nAuthor : David Abrahams, Jeremy Siek, Thomas Witt\nContact : dave@boost-consulting.com ,jsiek@osl.iu.edu ,witt@ive.uni-hannover.de\nOrganization :Boost Consulting , Indiana University Open Systems Lab , University of\nHanover Institute for Transport Railway Operation and Construction\nDate : 2004-11-01\nCopyright : Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003.\nabstract: indirect_iterator adapts an iterator by applying an extra dereference inside\nofoperator*() . For example, this iterator adaptor makes it possible to view a con-\ntainer of pointers (e.g. list<foo*> ) as if it were a container of the pointed-to type\n(e.g. list<foo> ).indirect_iterator depends on two auxiliary traits, pointee and\nindirect_reference , to provide support for underlying iterators whose value_type\nis not an iterator.\nTable of Contents\nindirect_iterator synopsis\nindirect_iterator requirements\nindirect_iterator models\nindirect_iterator operations\nExample\nindirect_iterator synopsis\ntemplate <\nclass Iterator\n, class Value = use_default\n, class CategoryOrTraversal = use_default\n, class Reference = use_default\n, class Difference = use_default\n>\nclass indirect_iterator\n{\npublic:\ntypedef /* see below */ value_type;\ntypedef /* see below */ reference;\ntypedef /* see below */ pointer;\ntypedef /* see below */ difference_type;\ntypedef /* see below */ iterator_category;\n1indirect_iterator();\nindirect_iterator(Iterator x);\ntemplate <\nclass Iterator2, class Value2, class Category2\n, class Reference2, class Difference2\n>\nindirect_iterator(\nindirect_iterator<\nIterator2, Value2, Category2, Reference2, Difference2\n> const& y\n, typename enable_if_convertible<Iterator2, Itera-\ntor>::type* = 0 // exposition\n);\nIterator const& base() const;\nreference operator*() const;\nindirect_iterator& operator++();\nindirect_iterator& operator--();\nprivate:\nIterator m_iterator; // exposition\n};\nThe member types of indirect_iterator are defined according to the following pseudo-code, where\nVisiterator_traits<Iterator>::value_type\nif (Value is use_default) then\ntypedef remove_const<pointee<V>::type>::type value_type;\nelse\ntypedef remove_const<Value>::type value_type;\nif (Reference is use_default) then\nif (Value is use_default) then\ntypedef indirect_reference<V>::type reference;\nelse\ntypedef Value& reference;\nelse\ntypedef Reference reference;\nif (Value is use_default) then\ntypedef pointee<V>::type* pointer;\nelse\ntypedef Value* pointer;\nif (Difference is use_default)\ntypedef iterator_traits<Iterator>::difference_type difference_type;\nelse\ntypedef Difference difference_type;\nif (CategoryOrTraversal is use_default)\ntypedef iterator-category (\niterator_traversal<Iterator>::type,‘‘reference‘‘,‘‘value_type‘‘\n) iterator_category;\nelse\n2typedef iterator-category (\nCategoryOrTraversal,‘‘reference‘‘,‘‘value_type‘‘\n) iterator_category;\nindirect_iterator requirements\nThe expression *v, where vis an object of iterator_traits<Iterator>::value_type , shall be valid\nexpression and convertible to reference .Iterator shall model the traversal concept indicated by it-\nerator_category .Value ,Reference , and Difference shall be chosen so that value_type ,reference ,\nanddifference_type meet the requirements indicated by iterator_category .\n[Note: there are further requirements on the iterator_traits<Iterator>::value_type if the\nValue parameter is not use_default , as implied by the algorithm for deducing the default for the\nvalue_type member.]\nindirect_iterator models\nIn addition to the concepts indicated by iterator_category and by iterator_traversal<indirect_iterator>::type ,\na specialization of indirect_iterator models the following concepts, Where vis an object of itera-\ntor_traits<Iterator>::value_type :\n•Readable Iterator if reference(*v) is convertible to value_type .\n•Writable Iterator if reference(*v) = t is a valid expression (where tis an object of\ntype indirect_iterator::value_type )\n•Lvalue Iterator if reference is a reference type.\nindirect_iterator<X,V1,C1,R1,D1> is interoperable with indirect_iterator<Y,V2,C2,R2,D2>\nif and only if Xis interoperable with Y.\nindirect_iterator operations\nIn addition to the operations required by the concepts described above, specializations of indirect_iterator\nprovide the following operations.\nindirect_iterator();\nRequires: Iterator must be Default Constructible.\nEffects: Constructs an instance of indirect_iterator with a default-constructed m_iterator .\nindirect_iterator(Iterator x);\nEffects: Constructs an instance of indirect_iterator with m_iterator copy constructed\nfrom x.\ntemplate <\nclass Iterator2, class Value2, unsigned Access, class Traversal\n, class Reference2, class Difference2\n>\nindirect_iterator(\nindirect_iterator<\nIterator2, Value2, Access, Traversal, Reference2, Difference2\n> const& y\n, typename enable_if_convertible<Iterator2, Iterator>::type* = 0 // expo-\nsition\n);\n3Requires: Iterator2 is implicitly convertible to Iterator .\nEffects: Constructs an instance of indirect_iterator whose m_iterator subobject is\nconstructed from y.base() .\nIterator const& base() const;\nReturns: m_iterator\nreference operator*() const;\nReturns: **m_iterator\nindirect_iterator& operator++();\nEffects: ++m_iterator\nReturns: *this\nindirect_iterator& operator--();\nEffects: --m_iterator\nReturns: *this\nExample\nThis example prints an array of characters, using indirect_iterator to access the array of characters\nthrough an array of pointers. Next indirect_iterator is used with the transform algorithm to copy\nthe characters (incremented by one) to another array. A constant indirect iterator is used for the source\nand a mutable indirect iterator is used for the destination. The last part of the example prints the\noriginal array of characters, but this time using the make_indirect_iterator helper function.\nchar characters[] = \"abcdefg\";\nconst int N = sizeof(characters)/sizeof(char) - 1; // -\n1 since characters has a null char\nchar* pointers_to_chars[N]; // at the end.\nfor (int i = 0; i < N; ++i)\npointers_to_chars[i] = &characters[i];\n// Example of using indirect_iterator\nboost::indirect_iterator<char**, char>\nindirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N);\nstd::copy(indirect_first, indi-\nrect_last, std::ostream_iterator<char>(std::cout, \",\"));\nstd::cout << std::endl;\n// Example of making mutable and constant indirect iterators\nchar mutable_characters[N];\nchar* pointers_to_mutable_chars[N];\nfor (int j = 0; j < N; ++j)\npointers_to_mutable_chars[j] = &mutable_characters[j];\n4boost::indirect_iterator<char* const*> muta-\nble_indirect_first(pointers_to_mutable_chars),\nmutable_indirect_last(pointers_to_mutable_chars + N);\nboost::indirect_iterator<char* const*, char const> const_indirect_first(pointers_to_chars),\nconst_indirect_last(pointers_to_chars + N);\nstd::transform(const_indirect_first, const_indirect_last,\nmutable_indirect_first, std::bind1st(std::plus<char>(), 1));\nstd::copy(mutable_indirect_first, mutable_indirect_last,\nstd::ostream_iterator<char>(std::cout, \",\"));\nstd::cout << std::endl;\n// Example of using make_indirect_iterator()\nstd::copy(boost::make_indirect_iterator(pointers_to_chars),\nboost::make_indirect_iterator(pointers_to_chars + N),\nstd::ostream_iterator<char>(std::cout, \",\"));\nstd::cout << std::endl;\nThe output is:\na,b,c,d,e,f,g,\nb,c,d,e,f,g,h,\na,b,c,d,e,f,g,\nThe source code for this example can be found here.\n5" } ]
{ "category": "App Definition and Development", "file_name": "indirect_iterator.pdf", "project_name": "ArangoDB", "subcategory": "Database" }
[ { "data": "event_23312\nevent_23481\nevent_23593\n...\nevent_1234\nevent_2345\n...event_3456\nevent_4567\n...\nevent_5678\nevent_6789\n...event_7890\nevent_8901\n...Disk and persisted indexesHeap and in-memory index\nPersistevent_34982\nevent_35789\nevent_36791\n...\nevent_1234\nevent_2345\n...event_3456\nevent_4567\n...\nevent_5678\nevent_6789\n...event_7890\nevent_8901\n...Off-heap memory and \npersisted indexes\nLoadQueries\n" } ]
{ "category": "App Definition and Development", "file_name": "realtime_flow.pdf", "project_name": "Druid", "subcategory": "Database" }
[ { "data": "Boost.P ool\nStephen Clear y\nCopyright © 2000-2006 Stephen Clear y\nCopyright © 2011 P aul A. Bristow\nDistrib uted under the Boost Softw are License, Version 1.0. (See accompan ying file LICENSE_1_0.txt or cop y at\nhttp://www .boost.or g/LICENSE_1_0.txt )\nTable of Contents\nIntroduction and Ov ervie w.......................................................................................................................................2\nDocumentation Naming and F ormatting Con ventions ............................................................................................2\nIntroduction ..................................................................................................................................................2\nHow do I use Pool? ........................................................................................................................................3\nInstallation ....................................................................................................................................................3\nBuilding the Test Programs ..............................................................................................................................3\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one. .........................................................3\nPool in More Depth ......................................................................................................................................10\nBoost.Pool C++ Reference .....................................................................................................................................22\nHeader <boost/pool/object_pool.hpp> ..............................................................................................................22\nHeader <boost/pool/pool.hpp> ........................................................................................................................25\nHeader <boost/pool/pool_alloc.hpp> ................................................................................................................31\nHeader <boost/pool/poolfwd.hpp> ...................................................................................................................41\nHeader <boost/pool/simple_se gregated_storage.hpp> ..........................................................................................41\nHeader <boost/pool/singleton_pool.hpp> ..........................................................................................................45\nAppendices .........................................................................................................................................................50\nAppendix A: History .....................................................................................................................................50\nAppendix B: F AQ.........................................................................................................................................50\nAppendix C: Ackno wledgements .....................................................................................................................50\nAppendix D: Tests........................................................................................................................................50\nAppendix E: Tickets......................................................................................................................................50\nAppendix F: Other Implementations .................................................................................................................51\nAppendix G: References ................................................................................................................................51\nAppendix H: Future plans ..............................................................................................................................52\nIndexes...............................................................................................................................................................53\n1\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Introduction and Over view\nDocumentation Naming and Formatting Con ventions\nThis documentation mak es use of the follo wing naming and formatting con ventions.\n•Code is in fixedwidthfont and is syntax-highlighted in color .\n•Replaceable te xt that you will need to supply is in italics .\n•Free functions are rendered in the codefont follo wed by (), as in free_function ().\n•If a name refers to a class template, it is specified lik e this: class_template <>; that is, it is in code font and its name is follo wed\nby <> to indicate that it is a class template.\n•If a name refers to a function-lik e macro, it is specified lik e this: MACRO(); that is, it is uppercase in code font and its name is\nfollowed by () to indicate that it is a function-lik e macro. Object-lik e macros appear without the trailing ().\n•Names that refer to concepts in the generic programming sense are specified in CamelCase.\nNote\nIn addition, notes such as this one specify non-essential information that pro vides additional background or rationale.\nFinally , you can mentally add the follo wing to an y code fragments in this document:\n// Include all of Pool files\n#include <boost/pool.hpp>\nIntroduction\nWhat is P ool?\nPool allocation is a memory allocation scheme that is v ery f ast, b ut limited in its usage. F or more information on pool allocation\n(also called simple se gregated stor age, see concepts concepts and Simple Se gregated Storage ).\nWhy should I use P ool?\nUsing Pools gi ves you more control o ver ho w memory is used in your program. F or example, you could ha ve a situation where you\nwant to allocate a b unch of small objects at one point, and then reach a point in your program where none of them are needed an y\nmore. Using pool interf aces, you can choose to run their destructors or just drop them of f into obli vion; the pool interf ace will\nguarantee that there are no system memory leaks.\nWhen should I use P ool?\nPools are generally used when there is a lot of allocation and deallocation of small objects. Another common usage is the situation\nabove, where man y objects may be dropped out of memory .\nIn general, use Pools when you need a more efficient w ay to do unusual memory control.\nWhic h pool allocator should I use?\npool_allocator is a more general-purpose solution, geared to wards efficiently servicing requests for an y number of contiguous\nchunks.\nfast_pool_allocator is also a general-purpose solution b ut is geared to wards efficiently servicing requests for one chunk at a\ntime; it will w ork for contiguous chunks, b ut not as well as pool_allocator .\n2Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/If you are seriously concerned about performance, use fast_pool_allocator when dealing with containers such as std::list ,\nand use pool_allocator when dealing with containers such as std::vector .\nHow do I use P ool?\nSee the Pool Interf aces section that co vers the dif ferent Pool interf aces supplied by this library .\nLibrar y Structure and Dependencies\nForward declarations of all the e xposed symbols for this library are in the header made inscope by #include\n<boost/pool/poolfwd.hpp>.\nThe library may use macros, which will be prefix ed with BOOST_POOL_ . The e xception to this rule are the include file guards, which\n(for file xxx.hpp) is BOOST_xxx_HPP .\nAll e xposed symbols defined by the library will be in namespace boost::. All symbols used only by the implementation will be in\nnamespace boost::details::pool.\nEvery header used only by the implementation is in the subdirectory /detail/.\nAny header in the library may include an y other header in the library or an y system-supplied header at its discretion.\nInstallation\nThe Boost Pool library is a header -only library . That means there is no .lib, .dll, or .so to b uild; just add the Boost directory to your\ncompiler's include file path, and you should be good to go!\nBuilding the Test Pr ograms\nA jamfile.v2 is pro vided which can be run is the usual w ay, for e xample:\nboost\\libs\\pool\\test>bjam-a>pool_test .log\nBoost P ool Interfaces - What interfaces are pr ovided and when\nto use eac h one .\nIntroduction\nThere are se veral interf aces pro vided which allo w users great fle xibility in ho w the y want to use Pools. Re view the concepts document\nto get the basic understanding of ho w the v arious pools w ork.\nTerminology and Tradeoffs\nObject Usa ge vs. Singleton Usa ge\nObject Usage is the method where each Pool is an object that may be created and destro yed. Destro ying a Pool implicitly frees all\nchunks that ha ve been allocated from it.\nSingleton Usage is the method where each Pool is an object with static duration; that is, it will not be destro yed until program e xit.\nPool objects with Singleton Usage may be shared; thus, Singleton Usage implies thread-safety as well. System memory allocated\nby Pool objects with Singleton Usage may be freed through release_memory or pur ge_memory .\nOut-of-Memor y Conditions: Exceptions vs. Null Return\nSome Pool interf aces thro w exceptions when out-of-memory; others will return0. In general, unless mandated by the Standard,\nPool interf aces will al ways prefer to return0 instead of thro wing an e xception.\n3Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Ordered ver sus unor dered\nAn ordered pool maintains it's free list in order of the address of each free block - this is the most efficient w ay if you're lik ely to\nallocate arrays of objects. Ho wever, freeing an object can be O(N) in the number of currently free blocks which can be prohibiti vely\nexpensi ve in some situations.\nAn unordered pool does not maintain it's free list in an y particular order , as a result allocation and freeing single objects is v ery fast,\nbut allocating arrays may be slo w (and in particular the pool may not be a ware that it contains enough free memory for the allocation\nrequest, and unnecessarily allocate more memory).\nPool Interfaces\npool\nThe pool interf ace is a simple Object Usage interf ace with Null Return.\npool is a f ast memory allocator , and guarantees proper alignment of all allocated chunks.\npool.hpp provides tw o UserAllocator classes and a template class pool , which e xtends and generalizes the frame work\nprovided by the Simple Se gregated Storage solution. F or information on other pool-based interf aces, see the other Pool Interf aces.\nSynopsis\nThere are tw o UserAllocator classes pro vided. Both of them are in pool.hpp .\nThe def ault v alue for the template parameter UserAllocator is al ways default_user_allocator_new_delete .\n4Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/structdefault_user_allocator_new_delete\n{\ntypedef std::size_tsize_type ;\ntypedef std::ptrdiff_t difference_type ;\nstaticchar*malloc(constsize_type bytes)\n{returnnew(std::nothrow)char[bytes];}\nstaticvoidfree(char*constblock)\n{delete[]block;}\n};\nstructdefault_user_allocator_malloc_free\n{\ntypedef std::size_tsize_type ;\ntypedef std::ptrdiff_t difference_type ;\nstaticchar*malloc(constsize_type bytes)\n{returnreinterpret_cast <char*>(std::malloc(bytes));}\nstaticvoidfree(char*constblock)\n{std::free(block);}\n};\ntemplate <typename UserAllocator =default_user_allocator_new_delete >\nclasspool\n{\nprivate:\npool(constpool&);\nvoidoperator =(constpool&);\npublic:\ntypedef UserAllocator user_allocator ;\ntypedef typename UserAllocator ::size_type size_type ;\ntypedef typename UserAllocator ::difference_type difference_type ;\nexplicit pool(size_type requested_size );\n~pool();\nboolrelease_memory ();\nboolpurge_memory ();\nboolis_from(void*chunk)const;\nsize_type get_requested_size ()const;\nvoid*malloc();\nvoid*ordered_malloc ();\nvoid*ordered_malloc (size_type n);\nvoidfree(void*chunk);\nvoidordered_free (void*chunk);\nvoidfree(void*chunks,size_type n);\nvoidordered_free (void*chunks,size_type n);\n};\nExample:\n5Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/voidfunc()\n{\nboost::pool<>p(sizeof(int));\nfor(inti=0;i<10000;++i)\n{\nint*constt=p.malloc();\n...// Do something with t; don't take the time to free() it.\n}\n}// on function exit, p is destroyed, and all malloc()'ed ints are implicitly freed.\nObject_pool\nThe template class object_pool interf ace is an Object Usage interf ace with Null Return, b ut is a ware of the type of the object\nfor which it is allocating chunks. On destruction, an y chunks that ha ve been allocated from that object_pool will ha ve their de-\nstructors called.\nobject_pool.hpp provides a template type that can be used for f ast and efficient memory allocation. It also pro vides automatic\ndestruction of non-deallocated objects.\nFor information on other pool-based interf aces, see the other Pool Interf aces.\nSynopsis\ntemplate <typename ElementType ,typename UserAllocator =default_user_allocator_new_delete >\nclassobject_pool\n{\nprivate:\nobject_pool (constobject_pool &);\nvoidoperator =(constobject_pool &);\npublic:\ntypedef ElementType element_type ;\ntypedef UserAllocator user_allocator ;\ntypedef typename pool<UserAllocator >::size_type size_type ;\ntypedef typename pool<UserAllocator >::difference_type difference_type ;\nobject_pool ();\n~object_pool ();\nelement_type *malloc();\nvoidfree(element_type *p);\nboolis_from(element_type *p)const;\nelement_type *construct ();\n// other construct() functions\nvoiddestroy(element_type *p);\n};\nTemplate P arameters\nElementT ype\nThe template parameter is the type of object to allocate/deallocate. It must ha ve a non-thro wing destructor .\nUserAllocator\nDefines the method that the underlying Pool will use to allocate memory from the system. Def ault is def ault_user_allocator_ne w_delete.\nSee __ UserAllocator for details.\nExample: struct X { ... }; // has destructor with side-ef fects.\n6Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/voidfunc()\n{\nboost::object_pool <X>p;\nfor(inti=0;i<10000;++i)\n{\nX*constt=p.malloc();\n...// Do something with t; don't take the time to free() it.\n}\n}// on function exit, p is destroyed, and all destructors for the X objects are called.\nSingleton_pool\nThe singleton_pool interface at singleton_pool.hpp is a Singleton Usage interf ace with Null Return. It's just the same\nas the pool interf ace b ut with Singleton Usage instead.\nSynopsis\ntemplate <typename Tag,unsigned RequestedSize ,\ntypename UserAllocator =default_user_allocator_new_delete >\nstructsingleton_pool\n{\npublic:\ntypedef Tagtag;\ntypedef UserAllocator user_allocator ;\ntypedef typename pool<UserAllocator >::size_type size_type ;\ntypedef typename pool<UserAllocator >::difference_type difference_type ;\nstaticconstunsigned requested_size =RequestedSize ;\nprivate:\nstaticpool<size_type >p;// exposition only!\nsingleton_pool ();\npublic:\nstaticboolis_from(void*ptr);\nstaticvoid*malloc();\nstaticvoid*ordered_malloc ();\nstaticvoid*ordered_malloc (size_type n);\nstaticvoidfree(void*ptr);\nstaticvoidordered_free (void*ptr);\nstaticvoidfree(void*ptr,std::size_tn);\nstaticvoidordered_free (void*ptr,size_type n);\nstaticboolrelease_memory ();\nstaticboolpurge_memory ();\n};\nNotes\nThe underlying pool p referenced by the static functions in singleton_pool is actually declared in a w ay so that it is:\n•Thread-safe if there is only one thread running before main() begins and after main() ends. All of the static functions of\nsingleton_pool synchronize their access to p.\n•Guaranteed to be constructed before it is used, so that the simple static object in the synopsis abo ve would actually be an incorrect\nimplementation. The actual implementation to guarantee this is considerably more complicated.\nNote that a dif ferent underlying pool p exists for each dif ferent set of template parameters, including implementation-specific ones.\n7Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Template P arameters\nTag\nThe Tag template parameter allo ws dif ferent unbounded sets of singleton pools to e xist. F or example, the pool allocators use tw o\ntag classes to ensure that the tw o different allocator types ne ver share the same underlying singleton pool.\nTag is ne ver actually used by singleton_pool .\nRequestedSize The requested size of memory chunks to allocate. This is passed as a constructor parameter to the underlying pool.\nMust be greater than 0.\nUserAllocator\nDefines the method that the underlying pool will use to allocate memory from the system. See User Allocators for details.\nExample: struct MyPoolT ag { };\ntypedef boost::singleton_pool <MyPoolTag ,sizeof(int)>my_pool;\nvoidfunc()\n{\nfor(inti=0;i<10000;++i)\n{\nint*constt=my_pool::malloc();\n...// Do something with t; don't take the time to free() it.\n}\n// Explicitly free all malloc()'ed ints.\nmy_pool::purge_memory ();\n}\npool_allocator\nThe pool_allocator interface is a Singleton Usage interf ace with Exceptions. It is b uilt on the singleton_pool interf ace, and\nprovides a Standard Allocator -compliant class (for use in containers, etc.).\nIntroduction\npool_alloc.hpp\nProvides tw o template types that can be used for f ast and efficient memory allocation. These types both satisfy the Standard Alloc-\nator requirements [20.1.5] and the additional requirements in [20.1.5/4], so the y can be used with Standard or user -supplied containers.\nFor information on other pool-based interf aces, see the other Pool Interf aces.\nSynopsis\n8Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/structpool_allocator_tag {};\ntemplate <typename T,\ntypename UserAllocator =default_user_allocator_new_delete >\nclasspool_allocator\n{\npublic:\ntypedef UserAllocator user_allocator ;\ntypedef Tvalue_type ;\ntypedef value_type *pointer;\ntypedef constvalue_type *const_pointer ;\ntypedef value_type &reference ;\ntypedef constvalue_type &const_reference ;\ntypedef typename pool<UserAllocator >::size_type size_type ;\ntypedef typename pool<UserAllcoator >::difference_type difference_type ;\ntemplate <typename U>\nstructrebind\n{typedef pool_allocator <U,UserAllocator >other;};\npublic:\npool_allocator ();\npool_allocator (constpool_allocator &);\n// The following is not explicit, mimicking std::allocator [20.4.1]\ntemplate <typename U>\npool_allocator (constpool_allocator <U,UserAllocator >&);\npool_allocator &operator =(constpool_allocator &);\n~pool_allocator ();\nstaticpointer address(reference r);\nstaticconst_pointer address(const_reference s);\nstaticsize_type max_size ();\nstaticvoidconstruct (pointer ptr,constvalue_type &t);\nstaticvoiddestroy(pointer ptr);\nbooloperator ==(constpool_allocator &)const;\nbooloperator !=(constpool_allocator &)const;\nstaticpointer allocate (size_type n);\nstaticpointer allocate (size_type n,pointer);\nstaticvoiddeallocate (pointer ptr,size_type n);\n};\nstructfast_pool_allocator_tag {};\ntemplate <typename T\ntypename UserAllocator =default_user_allocator_new_delete >\nclassfast_pool_allocator\n{\npublic:\ntypedef UserAllocator user_allocator ;\ntypedef Tvalue_type ;\ntypedef value_type *pointer;\ntypedef constvalue_type *const_pointer ;\ntypedef value_type &reference ;\ntypedef constvalue_type &const_reference ;\ntypedef typename pool<UserAllocator >::size_type size_type ;\ntypedef typename pool<UserAllocator >::difference_type difference_type ;\ntemplate <typename U>\nstructrebind\n{typedef fast_pool_allocator <U,UserAllocator >other;};\n9Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/public:\nfast_pool_allocator ();\nfast_pool_allocator (constfast_pool_allocator &);\n// The following is not explicit, mimicking std::allocator [20.4.1]\ntemplate <typename U>\nfast_pool_allocator (constfast_pool_allocator <U,UserAllocator >&);\nfast_pool_allocator &operator =(constfast_pool_allocator &);\n~fast_pool_allocator ();\nstaticpointer address(reference r);\nstaticconst_pointer address(const_reference s);\nstaticsize_type max_size ();\nstaticvoidconstruct (pointer ptr,constvalue_type &t);\nstaticvoiddestroy(pointer ptr);\nbooloperator ==(constfast_pool_allocator &)const;\nbooloperator !=(constfast_pool_allocator &)const;\nstaticpointer allocate (size_type n);\nstaticpointer allocate (size_type n,pointer);\nstaticvoiddeallocate (pointer ptr,size_type n);\nstaticpointer allocate ();\nstaticvoiddeallocate (pointer ptr);\n};\nTemplate P arameters\nTThe first template parameter is the type of object to allocate/deallocate.\nUserAllocator Defines the method that the underlying Pool will use to allocate memory from the system. See User Allocators for\ndetails.\nExample:\nvoidfunc()\n{\nstd::vector<int,boost::pool_allocator <int>>v;\nfor(inti=0;i<10000;++i)\nv.push_back (13);\n}// Exiting the function does NOT free the system memory allocated by the pool allocator.\n// You must call\n// boost::singleton_pool<boost::pool_allocator_tag, sizeof(int)>::release_memory();\n// in order to force freeing the system memory.\nPool in More Depth\nBasic ideas behind pooling\nDynamic memory allocation has been a fundamental part of most computer systems since r oughly 1960... 1\nEveryone uses dynamic memory allocation. If you ha ve ever called malloc or ne w, then you ha ve used dynamic memory allocation.\nMost programmers ha ve a tendenc y to treat the heap as a “magic bag\"” : we ask it for memory , and it magically creates some for us.\nSometimes we run into problems because the heap is not magic.\nThe heap is limited. Ev en on lar ge systems (i.e., not embedded) with huge amounts of virtual memory a vailable, there is a limit.\nEveryone is a ware of the ph ysical limit, b ut there is a more subtle, 'virtual' limit, that limit at which your program (or the entire system)\nslows do wn due to the use of virtual memory . This virtual limit is much closer to your program than the ph ysical limit, especially\nif you are running on a multitasking system. Therefore, when running on a lar ge system, it is considered nice to mak e your program\n10Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/use as fe w resources as necessary , and release them as soon as possible. When using an embedded system, programmers usually\nhave no memory to w aste.\nThe heap is complicated. It has to satisfy an y type of memory request, for an y size, and do it f ast. The common approaches to memory\nmanagement ha ve to do with splitting the memory up into portions, and k eeping them ordered by size in some sort of a tree or list\nstructure. Add in other f actors, such as locality and estimating lifetime, and heaps quickly become v ery complicated. So complicated,\nin fact, that there is no kno wn perfect answer to the problem of ho w to do dynamic memory allocation. The diagrams belo w illustrate\nhow most common memory managers w ork: for each chunk of memory , it uses part of that memory to maintain its internal tree or\nlist structure. Ev en when a chunk is malloc'ed out to a program, the memory manager must save some information in it - usually just\nits size. Then, when the block is free'd, the memory manager can easily tell ho w lar ge it is.\nDynamic memor y allocation is often inefficient\nBecause of the complication of dynamic memory allocation, it is often inefficient in terms of time and/or space. Most memory alloc-\nation algorithms store some form of information with each memory block, either the block size or some relational information, such\nas its position in the internal tree or list structure. It is common for such header fields to tak e up one machine w ord in a block that\nis being used by the program. The ob vious disadv antage, then, is when small objects are dynamically allocated. F or example, if ints\nwere dynamically allocated, then automatically the algorithm will reserv e space for the header fields as well, and we end up with a\n50% w aste of memory . Of course, this is a w orst-case scenario. Ho wever, more modern programs are making use of small objects\non the heap; and that is making this problem more and more apparent. Wilson et. al. state that an a verage-case memory o verhead is\nabout ten to twenty percent 2. This memory o verhead will gro w higher as more programs use more smaller objects. It is this memory\noverhead that brings programs closer to the virtual limit.\nIn lar ger systems, the memory o verhead is not as big of a problem (compared to the amount of time it w ould tak e to w ork around\nit), and thus is often ignored. Ho wever, there are situations where man y allocations and/or deallocations of smaller objects are taking\nplace as part of a time-critical algorithm, and in these situations, the system-supplied memory allocator is often too slo w.\nSimple se gregated storage addresses both of these issues. Almost all memory o verhead is done a way with, and all allocations can\ntake place in a small amount of (amortized) constant time. Ho wever, this is done at the loss of generality; simple se gregated storage\nonly can allocate memory chunks of a single size.\n11Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Simple Segregated Stora ge\nSimple Se gregated Storage is the basic idea behind the Boost Pool library . Simple Se gregated Storage is the simplest, and probably\nthe fastest, memory allocation/deallocation algorithm. It be gins by partitioning a memory block into fix ed-size chunks. Where the\nblock comes from is not important until implementation time. A Pool is some object that uses Simple Se gregated Storage in this\nfashion. To illustrate:\nEach of the chunks in an y given block are al ways the same size. This is the fundamental restriction of Simple Se gregated Storage:\nyou cannot ask for chunks of dif ferent sizes. F or example, you cannot ask a Pool of inte gers for a character , or a Pool of characters\nfor an inte ger (assuming that characters and inte gers are dif ferent sizes).\nSimple Se gregated Storage w orks by interlea ving a free list within the unused chunks. F or example:\nBy interlea ving the free list inside the chunks, each Simple Se gregated Storage only has the o verhead of a single pointer (the pointer\nto the first element in the list). It has no memory o verhead for chunks that are in use by the process.\nSimple Se gregated Storage is also e xtremely f ast. In the simplest case, memory allocation is merely remo ving the first chunk from\nthe free list, a O(1) operation. In the case where the free list is empty , another block may ha ve to be acquired and partitioned, which\nwould result in an amortized O(1) time. Memory deallocation may be as simple as adding that chunk to the front of the free list, a\nO(1) operation. Ho wever, more complicated uses of Simple Se gregated Storage may require a sorted free list, which mak es dealloc-\nation O(N).\n12Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Simple Se gregated Storage gi ves faster e xecution and less memory o verhead than a system-supplied allocator , but at the loss of\ngenerality . A good place to use a Pool is in situations where man y (noncontiguous) small objects may be allocated on the heap, or\nif allocation and deallocation of the same-sized objects happens repeatedly .\nGuaranteeing Alignment - Ho w we guarantee alignment por tably.\nTerminology\nReview the concepts section if you are not already f amiliar with it. Remember that block is a contiguous section of memory , which\nis partitioned or se gregated into fix ed-size chunks. These chunks are what are allocated and deallocated by the user .\nOver view\nEach Pool has a single free list that can e xtend o ver a number of memory blocks. Thus, Pool also has a link ed list of allocated memory\nblocks. Each memory block, by def ault, is allocated using new[], and all memory blocks are freed on destruction. It is the use of\nnew[] that allo ws us to guarantee alignment.\nProof of Concept: Guaranteeing Alignment\nEach block of memory is allocated as a POD type (specifically , an array of characters) through operator new[]. Let POD_size\nbe the number of characters allocated.\nPredicate 1: Arra ys ma y not ha ve pad ding\nThis follo ws from the follo wing quote:\n[5.3.3/2] (Expressions::Unary e xpressions::Sizeof) ... When applied to an arr ay, the r esult is the total number of bytes in the arr ay.\nThis implies that the size of an arr ay of n elements is n times the size of an element.\nTherefore, arrays cannot contain padding, though the elements within the arrays may contain padding.\nPredicate 2: Any block of memor y allocated as an arra y of c haracter s through operator new[] (hereafter ref erred\nto as the b lock) is pr operl y aligned f or an y object of that siz e or smaller\nThis follo ws from:\n•[3.7.3.1/2] (Basic concepts::Storage duration::Dynamic storage duration::Allocation functions) \"... The pointer r eturned shall be\nsuitably aligned so that it can be con verted to a pointer of any complete object type and then used to access the object or arr ay\nin the stor age allocated ...\"\n•[5.3.4/10] (Expressions::Unary e xpressions::Ne w) \"... F or arr ays of c har and unsigned c har, the dif ference between the r esult of\nthe ne w-expression and the addr ess returned by the allocation function shall be an inte gral multiple of the most string ent alignment\n13Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/requir ement (3.9) of any object type whose size is no gr eater than the size of the arr ay being cr eated. [Note: Because allocation\nfunctions ar e assumed to r eturn pointer s to stor age that is appr opriately aligned for objects of any type , this constr aint on arr ay\nallocation o verhead permits the common idiom of allocating c haracter arr ays into whic h objects of other types will later be\nplaced.\"\nConsider: imaginar y object type Element of a siz e whic h is a m ultiple of some actual object siz e; assume\nsizeof (Element )>POD_size\nNote that an object of that size can e xist. One object of that size is an array of the \"actual\" objects.\nNote that the block is properly aligned for an Element. This directly follo ws from Predicate 2.\nCorollar y 1:The b lock is pr operl y aligned f or an arra y of Elements\nThis follo ws from Predicates 1 and 2, and the follo wing quote:\n[3.9/9] (Basic concepts::T ypes) \"An object type is a (possibly cv-qualified) type that is not a function type , not a r eference type , and\nnot a void type .\"\n(Specifically , array types are object types.)\nCorollar y 2: For an y pointer p and integ er i, if p is pr operl y aligned f or the type it points to, then p+i (when\nwell-defined) is pr operl y aligned f or that type; in other w ords, if an arra y is pr operl y aligned, then eac h element\nin that arra y is pr operl y aligned\nThere are no quotes from the Standard to directly support this ar gument, b ut it fits the common conception of the meaning of\n\"alignment\".\nNote that the conditions for p+i being well-defined are outlined in [5.7/5]. We do not quote that here, b ut only mak e note that it\nis well-defined if p and p+i both point into or one past the same array .\nLet: sizeof (Element ) be the least common m ultiple of siz es of se veral actual objects (T1, T2,T3, ...)\nLet: block be a pointer to the memor y block, pe be (Element *) b lock, and pn be (Tn *) b lock\nCorollar y 3: For eac h integ er i, such that pe+i is well-defined, then f or eac h n, there e xists some integ er jn\nsuch that pn+jn is well-defined and ref ers to the same memor y address as pe+i\nThis follo ws naturally , since the memory block is an array of Elements, and for each n, sizeof(Element)%sizeof(Tn)==\n0; thus, the boundary of each element in the array of Elements is also a boundary of each element in each array of Tn.\nTheorem: For eac h integ er i, such that pe+i is well-defined, that ad dress (pe + i) is pr operl y aligned f or eac h\ntype Tn\nSince pe+i is well-defined, then by Corollary 3, pn+jn is well-defined. It is properly aligned from Predicate 2 and Corollaries\n1 and 2.\nUse of the Theorem\nThe proof abo ve covers alignment requirements for cutting chunks out of a block. The implementation uses actual object sizes of:\n•The requested object size ( requested_size ); this is the size of chunks requested by the user\n•void* (pointer to v oid); this is because we interlea ve our free list through the chunks\n•size_type ; this is because we store the size of the ne xt block within each memory block\nEach block also contains a pointer to the ne xt block; b ut that is stored as a pointer to v oid and cast when necessary , to simplify\nalignment requirements to the three types abo ve.\n14Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Therefore, alloc_size is defined to be the lar gest of the sizes abo ve, rounded up to be a multiple of all three sizes. This guarantees\nalignment pro vided all alignments are po wers of tw o: something that appears to be true on all kno wn platforms.\nA Look at the Memor y Bloc k\nEach memory block consists of three main sections. The first section is the part that chunks are cut out of, and contains the interlea ved\nfree list. The second section is the pointer to the ne xt block, and the third section is the size of the ne xt block.\nEach of these sections may contain padding as necessary to guarantee alignment for each of the ne xt sections. The size of the first\nsection is number_of_chunks *lcm(requested_size ,sizeof(void*),sizeof(size_type )); the size of the second\nsection is lcm(sizeof(void*),sizeof(size_type ); and the size of the third section is sizeof(size_type ).\nHere's an e xample memory block, where requested_size ==sizeof(void*)==sizeof(size_type )==4:\nTo sho w a visual e xample of possible padding, here's an e xample memory block where requested_size ==8andsizeof(void\n*)==sizeof(size_type )==4\nHow Contiguous Chunks are Handled\nThe theorem abo ve guarantees all alignment requirements for allocating chunks and also implementation details such as the interlea ved\nfree list. Ho wever, it does so by adding padding when necessary; therefore, we ha ve to treat allocations of contiguous chunks in a\ndifferent w ay.\nUsing array ar guments similar to the abo ve, we can translate an y request for contiguous memory for n objects of requested_size\ninto a request for m contiguous chunks. m is simply ceil(n*requested_size /alloc_size ), where alloc_size is the\nactual size of the chunks.\nTo illustrate:\n15Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Here's an e xample memory block, where requested_size ==1 and sizeof(void*)==sizeof(size_type )==4:\nThen, when the user deallocates the contiguous memory , we can split it up into chunks ag ain.\nNote that the implementation pro vided for allocating contiguous chunks uses a linear instead of quadratic algorithm. This means\nthat it may not find contiguous free chunks if the free list is not ordered. Thus, it is recommended to al ways use an ordered free list\nwhen dealing with contiguous allocation of chunks. (In the e xample abo ve, if Chunk 1 pointed to Chunk 3 pointed to Chunk 2\npointed to Chunk 4, instead of being in order , the contiguous allocation algorithm w ould ha ve failed to find an y of the contiguous\nchunks).\nSimple Segregated Stora ge (Not f or the faint of hear t - Embed ded pr ogrammer s\nonly!)\nIntroduction\nsimple_segregated_storage.hpp provides a template class simple_se gregated_storage that controls access to a free list of\nmemory chunks.\nNote that this is a v ery simple class, with uncheck ed preconditions on almost all its functions. It is intended to be the f astest and\nsmallest possible quick memory allocator for e xample, something to use in embedded systems. This class dele gates man y difficult\npreconditions to the user (especially alignment issues). F or more general usage, see the other Pool Interf aces.\n16Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\ntemplate <typename SizeType = std::size_t>\nclass simple_segregated_storage\n{\n private:\n simple_segregated_storage(const simple_segregated_storage &);\n void operator=(const simple_segregated_storage &);\n public:\n typedef SizeType size_type;\n simple_segregated_storage();\n ~simple_segregated_storage();\n static void * segregate(void * block,\n size_type nsz, size_type npartition_sz,\n void * end = 0);\n void add_block(void * block,\n size_type nsz, size_type npartition_sz);\n void add_ordered_block(void * block,\n size_type nsz, size_type npartition_sz);\n bool empty() const;\n void * malloc();\n void free(void * chunk);\n void ordered_free(void * chunk);\n void * malloc_n(size_type n, size_type partition_sz);\n void free_n(void * chunks, size_type n,\n size_type partition_sz);\n void ordered_free_n(void * chunks, size_type n,\n size_type partition_sz);\n};\nSemantics\nAn object of type simple_segregated_storage <SizeType > is empty if its free list is empty . If it is not empty , then it is ordered\nif its free list is ordered. A free list is ordered if repeated calls to malloc() will result in a constantly-increasing sequence of v alues,\nas determined by std::less<void*>. A member function is order -preserving if the free-list maintains its order orientation (that\nis, an ordered free list is still ordered after the member function call).\nTable 1. Symbol Table\nMeaning Symbol\nsimple_se gregated_storage<SizeT ype> Store\nvalue of type Store t\nvalue of type const Store u\nvalues of type v oid * block, chunk, end\nvalues of type Store::size_type partition_sz, sz, n\n17Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Table 2. Template P arameters\nRequir ements Default Parameter\nAn unsigned inte gral type std::size_t SizeT ype\nTable 3. Typedefs\nType Symbol\nSizeT ype size_type\nTable 4. Constructors, Destructors, and State\nNotes Post-Condition Retur n Type Expr ession\nConstructs a ne w Store empty() not used Store()\nDestructs the Store not used (&t)->~Store()\nReturns true if u is empty . Or-\nder-preserving.bool u.empty()\n18Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Table 5. Segr egation\nNotes Semantic Equi val-\nencePost-Condition Pre-Condition Retur n Type Expr ession\nInterlea ves a free\nlist through the\nmemory block spe-\ncified by block of\nsize sz bytes, parti-\ntioning it into as\nmany partition_sz-\nsized chunks as\npossible. The last\nchunk is set to\npoint to end, and a\npointer to the first\nchunck is returned\n(this is al ways\nequal to block).\nThis interlea ved\nfree list is ordered.\nO(sz).partition_sz >=\nsizeof(v oid *) parti-\ntion_sz =\nsizeof(v oid *) * i,\nfor some inte ger i\nsz >= partition_sz\nblock is properly\naligned for an array\nof objects of size\npartition_sz block\nis properly aligned\nfor an array of v oid\n*void * Store::se greg-\nate(block, sz, parti-\ntion_sz, end)\nStore::se greg-\nate(block, sz, parti-\ntion_sz, 0)Same as abo ve void * Store::se greg-\nate(block, sz, parti-\ntion_sz)\nSegregates the\nmemory block spe-\ncified by block of\nsize sz bytes into\npartition_sz-sized\nchunks, and adds\nthat free list to its\nown. If t w as\nempty before this\ncall, then it is\nordered after this\ncall. O(sz).!t.empty() Same as abo ve void t.add_block(block,\nsz, partition_sz)\nSegregates the\nmemory block spe-\ncified by block of\nsize sz bytes into\npartition_sz-sized\nchunks, and mer ges\nthat free list into its\nown. Order -pre-\nserving. O(sz).!t.empty() Same as abo ve void t.add_ordered_block(block,\nsz, partition_sz)\n19Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Table 6. Allocation and Deallocation\nNotes Semantic Equi val-\nencePost-Condition Pre-Condition Retur n Type Expr ession\nTakes the first\navailable chunk!t.empty() void * t.malloc()\nfrom the free list\nand returns it. Or -\nder-preserving.\nO(1).\nPlaces chunk back\non the free list.!t.empty() chunk w as pre vi-\nously returnedvoid t.free(chunk)\nNote that chunk\nmay not be 0. O(1).from a call to\nt.malloc()\nPlaces chunk back\non the free list.!t.empty() Same as abo ve void t.ordered_free(chunk)\nNote that chunk\nmay not be 0. Or -\nder-preserving.\nO(N) with respect\nto the size of the\nfree list.\nAttempts to find a\ncontiguous se-void * t.malloc_n(n, parti-\ntion_sz)\nquence of n parti-\ntion_sz-sized\nchunks. If found,\nremo ves them all\nfrom the free list\nand returns a point-\ner to the first. If not\nfound, returns 0. It\nis strongly recom-\nmended (b ut not re-\nquired) that the free\nlist be ordered, as\nthis algorithm will\nfail to find a con-\ntiguous sequence\nunless it is contigu-\nous in the free list\nas well. Order -pre-\nserving. O(N) with\nrespect to the size\nof the free list.\n20Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Notes Semantic Equi val-\nencePost-Condition Pre-Condition Retur n Type Expr ession\nAssumes that\nchunk actually\nrefers to a block of\nchunks spanning n\n* partition_sz\nbytes; se gregates\nand adds in that\nblock. Note that\nchunk may not be\n0. O(n).t.add_block(chunk,\nn * partition_sz,\npartition_sz)!t.empty() chunk w as pre vi-\nously returned\nfrom a call to\nt.malloc_n(n, parti-\ntion_sz)void t.free_n(chunk, n,\npartition_sz)\nSame as abo ve, ex-\ncept it mer ges in\nthe free list. Order -\npreserving. O(N +\nn) where N is the\nsize of the free list.t.add_ordered_block(chunk,\nn * partition_sz,\npartition_sz)same as abo ve same as abo ve void t.ordered_free_n(chunk,\nn, partition_sz)\nThe UserAllocator Concept\nPool objects need to request memory blocks from the system, which the Pool then splits into chunks to allocate to the user . By spe-\ncifying a UserAllocator template parameter to v arious Pool interf aces, users can control ho w those system memory blocks are allocated.\nIn the follo wing table, UserAllocator is a User Allocator type, block is a v alue of type char *, and n is a v alue of type UserAllocat-\nor::size_type\nTable 7. UserAllocator Requir ements\nDescription Result Expr ession\nAn unsigned inte gral type that can repres-\nent the size of the lar gest object to be al-\nlocated.UserAllocator::size_type\nA signed inte gral type that can represent\nthe dif ference of an y two pointers.UserAllocator::dif ference_type\nAttempts to allocate n bytes from the\nsystem. Returns 0 if out-of-memory .char * UserAllocator::malloc(n)\nblock must ha ve been pre viously returned\nfrom a call to UserAllocator::malloc.void UserAllocator::free(block)\nThere are tw o UserAllocator classes pro vided in this library: default_user_allocator_new_delete and default_user_al-\nlocator_malloc_free , both in pool.hpp. The def ault v alue for the template parameter UserAllocator is al ways default_user_al-\nlocator_new_delete .\n21Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Boost.P ool C++ Ref erence\nHeader < boost/pool/object_pool.hpp >\nProvides a template type boost::object_pool<T , UserAllocator> that can be used for f ast and efficient memory allocation of objects\nof type T. It also pro vides automatic destruction of non-deallocated objects.\nnamespace boost{\ntemplate <typename T,typename UserAllocator >classobject_pool ;\n}\nClass template object_pool\nboost::object_pool —A template class that can be used for f ast and efficient memory allocation of objects. It also pro vides automatic\ndestruction of non-deallocated objects.\nSynopsis\n// In header: < boost/pool/object_pool.hpp >\ntemplate <typename T,typename UserAllocator >\nclassobject_pool :protected boost::pool<UserAllocator >{\npublic:\n// types\ntypedef T element_type ;// ElementType. \ntypedef UserAllocator user_allocator ;// User allocator. \ntypedef pool<UserAllocator >::size_type size_type ; // pool<UserAllocat ↵\nor>::size_type \ntypedef pool<UserAllocator >::difference_type difference_type ;// pool<UserAllocator>::dif ↵\nference_type \n// construct/copy/destruct\nexplicit object_pool (constsize_type =32,constsize_type =0);\n~object_pool ();\n// protected member functions\npool<UserAllocator >&store();\nconstpool<UserAllocator >&store()const;\n// protected static functions\nstaticvoid*&nextof(void*const);\n// public member functions\nelement_type *malloc();\nvoidfree(element_type *const);\nboolis_from(element_type *const)const;\nelement_type *construct ();\ntemplate <typename Arg1,...class ArgN>\nelement_type *construct (Arg1&,...ArgN&);\nvoiddestroy(element_type *const);\nsize_type get_next_size ()const;\nvoidset_next_size (constsize_type );\n};\nDescription\nTThe type of object to allocate/deallocate. T must ha ve a non-thro wing destructor .\n22Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/UserAllocator Defines the allocator that the underlying Pool will use to allocate memory from the system. See User Allocators for\ndetails.\nClass object_pool is a template class that can be used for f ast and efficient memory allocation of objects. It also pro vides automatic\ndestruction of non-deallocated objects.\nWhen the object pool is destro yed, then the destructor for type T is called for each allocated T that has not yet been deallocated.\nO(N).\nWhene ver an object of type ObjectPool needs memory from the system, it will request it from its UserAllocator template parameter .\nThe amount requested is determined using a doubling algorithm; that is, each time more system memory is allocated, the amount of\nsystem memory requested is doubled. Users may control the doubling algorithm by the parameters passed to the object_pool's con-\nstructor .\nobject_pool pub lic construct/cop y/destruct\n1.explicit object_pool (constsize_type arg_next_size =32,\nconstsize_type arg_max_size =0);\nConstructs a ne w (empty by def ault) ObjectPool.\nRequires: next_size != 0.\n2.~object_pool ();\nobject_pool protected member functions\n1.pool<UserAllocator >&store();\nReturns: The underlying boost:: pool storage used by *this.\n2.constpool<UserAllocator >&store()const;\nReturns: The underlying boost:: pool storage used by *this.\nobject_pool protected static functions\n1.staticvoid*&nextof(void*const ptr);\nReturns: The ne xt memory block after ptr (for the sak e of code readability :)\nobject_pool pub lic member functions\n1.element_type *malloc();\nAllocates memory that can hold one object of type ElementT ype.\nIf out of memory , returns 0.\nAmortized O(1).\n2.voidfree(element_type *const chunk);\nDe-Allocates memory that holds a chunk of type ElementT ype.\n23Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Note that p may not be 0.\nNote that the destructor for p is not called. O(N).\n3.boolis_from(element_type *const chunk)const;\nReturns f alse if chunk w as allocated from some other pool or may be returned as the result of a future allocation from some other\npool.\nOtherwise, the return v alue is meaningless.\nNote\nThis function may NO T be used to reliably test random pointer v alues!\nReturns: true if chunk w as allocated from *this or may be returned as the result of a future allocation from *this.\n4.element_type *construct ();\nReturns: A pointer to an object of type T, allocated in memory from the underlying pool and def ault constructed. The returned\nobjected can be freed by a call to destro y. Otherwise the returned object will be automatically destro yed when *this\nis destro yed.\n5.template <typename Arg1,...class ArgN>\nelement_type *construct (Arg1&,...ArgN&);\nNote\nSince the number and type of ar guments to this function is totally arbitrary , a simple system has been set up to\nautomatically generate template construct functions. This system is based on the macro preprocessor m4, which\nis standard on UNIX systems and also a vailable for Win32 systems.\ndetail/pool_construct.m4, when run with m4, will create the file detail/pool_construct.ipp, which only defines\nthe construct functions for the proper number of ar guments. The number of ar guments may be passed into the\nfile as an m4 macro, NumberOfAr guments; if not pro vided, it will def ault to 3.\nFor each dif ferent number of ar guments (1 to NumberOfAr guments), a template function is generated. There are\nthe same number of template parameters as there are ar guments, and each ar gument's type is a reference to that\n(possibly cv-qualified) template ar gument. Each possible permutation of the cv-qualifications is also generated.\nBecause each permutation is generated for each possible number of ar guments, the included file size gro ws ex-\nponentially in terms of the number of constructor ar guments, not linearly . For the sak e of rational compile times,\nonly use as man y arguments as you need.\ndetail/pool_construct.bat and detail/pool_construct.sh are also pro vided to call m4, defining NumberOfAr guments\nto be their command-line parameter . See these files for more details.\nReturns: A pointer to an object of type T, allocated in memory from the underlying pool and constructed from ar guments\nArg1 to ArgN. The returned objected can be freed by a call to destro y. Otherwise the returned object will be auto-\nmatically destro yed when *this is destro yed.\n6.voiddestroy(element_type *const chunk);\nDestro ys an object allocated with construct.\nEquivalent to:\np->~ElementT ype(); this->free(p);\n24Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Requires: p must ha ve been pre viously allocated from *this via a call to construct.\n7.size_type get_next_size ()const;\nReturns: The number of chunks that will be allocated ne xt time we run out of memory .\n8.voidset_next_size (constsize_type x);\nSet a ne w number of chunks to allocate the ne xt time we run out of memory .\nParameters: xwanted ne xt_size (must not be zero).\nHeader < boost/pool/pool.hpp >\nProvides class pool: a f ast memory allocator that guarantees proper alignment of all allocated chunks, and which e xtends and gener -\nalizes the frame work pro vided by the simple se gregated storage solution. Also pro vides tw o UserAllocator classes which can be\nused in conjuction with pool.\nnamespace boost{\nstructdefault_user_allocator_new_delete ;\nstructdefault_user_allocator_malloc_free ;\ntemplate <typename UserAllocator >classpool;\n}\nStruct default_user_allocator_ne w_delete\nboost::def ault_user_allocator_ne w_delete —Allocator used as the def ault template parameter for a UserAllocator template parameter .\nUses ne w and delete.\nSynopsis\n// In header: < boost/pool/pool.hpp >\nstructdefault_user_allocator_new_delete {\n// types\ntypedef std::size_t size_type ; // An unsigned integral type that can represent the ↵\nsize of the largest object to be allocated. \ntypedef std::ptrdiff_t difference_type ;// A signed integral type that can represent the dif ↵\nference of any two pointers. \n// public static functions\nstaticchar*malloc(constsize_type );\nstaticvoidfree(char*const);\n};\nDescription\ndefault_user_allocator_new_delete pub lic static functions\n1.staticchar*malloc(constsize_type bytes);\nAttempts to allocate n bytes from the system. Returns 0 if out-of-memory\n25Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/2.staticvoidfree(char*const block);\nAttempts to de-allocate block.\nRequires: Block must ha ve been pre viously returned from a call to UserAllocator::malloc.\nStruct default_user_allocator_malloc_free\nboost::def ault_user_allocator_malloc_free —UserAllocator used as template parameter for pool and object_pool . Uses malloc and\nfree internally .\nSynopsis\n// In header: < boost/pool/pool.hpp >\nstructdefault_user_allocator_malloc_free {\n// types\ntypedef std::size_t size_type ; // An unsigned integral type that can represent the ↵\nsize of the largest object to be allocated. \ntypedef std::ptrdiff_t difference_type ;// A signed integral type that can represent the dif ↵\nference of any two pointers. \n// public static functions\nstaticchar*malloc(constsize_type );\nstaticvoidfree(char*const);\n};\nDescription\ndefault_user_allocator_malloc_free pub lic static functions\n1.staticchar*malloc(constsize_type bytes);\n2.staticvoidfree(char*const block);\nClass template pool\nboost::pool —A fast memory allocator that guarantees proper alignment of all allocated chunks.\n26Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/pool.hpp >\ntemplate <typename UserAllocator >\nclasspool:\nprotected boost::simple_segregated_storage <UserAllocator ::size_type >\n{\npublic:\n// types\ntypedef UserAllocator user_allocator ;// User allocator. \ntypedef UserAllocator ::size_type size_type ; // An unsigned integral type that ↵\ncan represent the size of the largest object to be allocated. \ntypedef UserAllocator ::difference_type difference_type ;// A signed integral type that can ↵\nrepresent the difference of any two pointers. \n// construct/copy/destruct\nexplicit pool(constsize_type ,constsize_type =32,constsize_type =0);\n~pool();\n// private member functions\nvoid*malloc_need_resize ();\nvoid*ordered_malloc_need_resize ();\n// protected member functions\nsimple_segregated_storage <size_type >&store();\nconstsimple_segregated_storage <size_type >&store()const;\n details::PODptr <size_type >find_POD (void*const)const;\nsize_type alloc_size ()const;\n// protected static functions\nstaticboolis_from(void*const,char*const,constsize_type );\nstaticvoid*&nextof(void*const);\n// public member functions\nboolrelease_memory ();\nboolpurge_memory ();\nsize_type get_next_size ()const;\nvoidset_next_size (constsize_type );\nsize_type get_max_size ()const;\nvoidset_max_size (constsize_type );\nsize_type get_requested_size ()const;\nvoid*malloc();\nvoid*ordered_malloc ();\nvoid*ordered_malloc (size_type );\nvoidfree(void*const);\nvoidordered_free (void*const);\nvoidfree(void*const,constsize_type );\nvoidordered_free (void*const,constsize_type );\nboolis_from(void*const)const;\n};\nDescription\nWhene ver an object of type pool needs memory from the system, it will request it from its UserAllocator template parameter . The\namount requested is determined using a doubling algorithm; that is, each time more system memory is allocated, the amount of\nsystem memory requested is doubled.\nUsers may control the doubling algorithm by using the follo wing e xtensions:\nUsers may pass an additional constructor parameter to pool. This parameter is of type size_type, and is the number of chunks to request\nfrom the system the first time that object needs to allocate system memory . The def ault is 32. This parameter may not be 0.\n27Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Users may also pass an optional third parameter to pool's constructor . This parameter is of type size_type, and sets a maximum size\nfor allocated chunks. When this parameter tak es the def ault v alue of 0, then there is no upper limit on chunk size.\nFinally , if the doubling algorithm results in no memory being allocated, the pool will backtrack just once, halving the chunk size\nand trying ag ain.\nUserAllocator type - the method that the Pool will use to allocate memory from the system.\nThere are essentially tw o ways to use class pool: the client can call malloc() and free() to allocate and free single chunks of memory ,\nthis is the most efficient w ay to use a pool, b ut does not allo w for the efficient allocation of arrays of chunks. Alternati vely, the client\nmay call ordered_malloc() and ordered_free(), in which case the free list is maintained in an ordered state, and efficient allocation\nof arrays of chunks are possible. Ho wever, this latter option can suf fer from poor performance when lar ge numbers of allocations\nare performed.\npool pub lic construct/cop y/destruct\n1.explicit pool(constsize_type nrequested_size ,\nconstsize_type nnext_size =32,constsize_type nmax_size =0);\nConstructs a ne w empty Pool that can be used to allocate chunks of size RequestedSize.\nParameters: nmax_size is the maximum number of chunks to allocate in one block.\nnnext_size parameter is of type size_type, is the number of chunks to request from the system\nthe first time that object needs to allocate system memory . The def ault is 32. This\nparameter may not be 0.\nnrequested_size Requested chunk size\n2.~pool();\nDestructs the Pool, freeing its list of memory blocks.\npool priv ate member functions\n1.void*malloc_need_resize ();\nNo memory in an y of our storages; mak e a ne w storage, Allocates chunk in ne wly malloc aftert resize.\nReturns: 0 if out-of-memory . Called if malloc/ordered_malloc needs to resize the free list.\nReturns: pointer to chunk.\n2.void*ordered_malloc_need_resize ();\nCalled if malloc needs to resize the free list.\nNo memory in an y of our storages; mak e a ne w storage,\nReturns: pointer to ne w chunk.\npool protected member functions\n1.simple_segregated_storage <size_type >&store();\nReturns: pointer to store.\n2.constsimple_segregated_storage <size_type >&store()const;\nReturns: pointer to store.\n28Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/3.details::PODptr <size_type >find_POD (void*const chunk)const;\nfinds which POD in the list 'chunk' w as allocated from.\nfind which PODptr storage memory that this chunk is from.\nReturns: the PODptr that holds this chunk.\n4.size_type alloc_size ()const;\nCalculated size of the memory chunks that will be allocated by this Pool.\nReturns: allocated size.\npool protected static functions\n1.staticboolis_from(void*const chunk,char*const i,\nconstsize_type sizeof_i );\nReturns f alse if chunk w as allocated from some other pool, or may be returned as the result of a future allocation from some\nother pool. Otherwise, the return v alue is meaningless.\nNote that this function may not be used to reliably test random pointer v alues.\nParameters: chunk to check if is from this pool. chunk\ni memory chunk at i with element sizeof_i.\nsizeof_i element size (size of the chunk area of that block, not the total size of that block).\nReturns: true if chunk w as allocated or may be returned. as the result of a future allocation.\n2.staticvoid*&nextof(void*const ptr);\nReturns: Pointer dereferenced. (Pro vided and used for the sak e of code readability :)\npool pub lic member functions\n1.boolrelease_memory ();\npool must be ordered. Frees e very memory block that doesn't ha ve any allocated chunks.\nReturns: true if at least one memory block w as freed.\n2.boolpurge_memory ();\npool must be ordered. Frees e very memory block.\nThis function in validates an y pointers pre viously returned by allocation functions of t.\nReturns: true if at least one memory block w as freed.\n3.size_type get_next_size ()const;\nNumber of chunks to request from the system the ne xt time that object needs to allocate system memory . This v alue should ne ver\nbe 0.\nReturns: next_size;\n4.voidset_next_size (constsize_type nnext_size );\nSet number of chunks to request from the system the ne xt time that object needs to allocate system memory . This v alue should\nnever be set to 0.\n29Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Returns: nnext_size.\n5.size_type get_max_size ()const;\nReturns: max_size.\n6.voidset_max_size (constsize_type nmax_size );\nSet max_size.\n7.size_type get_requested_size ()const;\nReturns: the requested size passed into the constructor . (This v alue will not change during the lifetime of a Pool object).\n8.void*malloc();\nAllocates a chunk of memory . Searches in the list of memory blocks for a block that has a free chunk, and returns that free chunk\nif found. Otherwise, creates a ne w memory block, adds its free list to pool's free list,\nReturns: a free chunk from that block. If a ne w memory block cannot be allocated, returns 0. Amortized O(1).\n9.void*ordered_malloc ();\nSame as malloc, only mer ges the free lists, to preserv e order . Amortized O(1).\nReturns: a free chunk from that block. If a ne w memory block cannot be allocated, returns 0. Amortized O(1).\n10.void*ordered_malloc (size_type n);\nGets address of a chunk n, allocating ne w memory if not already a vailable.\nReturns: Address of chunk n if allocated ok.\n0 if not enough memory for n chunks.\n11.voidfree(void*const chunk);\nSame as malloc, only allocates enough contiguous chunks to co ver n * requested_size bytes. Amortized O(n).\nDeallocates a chunk of memory . Note that chunk may not be 0. O(1).\nChunk must ha ve been pre viously returned by t.malloc() or t.ordered_malloc(). Assumes that chunk actually refers to a block of\nchunks spanning n * partition_sz bytes. deallocates each chunk in that block. Note that chunk may not be 0. O(n).\nReturns: a free chunk from that block. If a ne w memory block cannot be allocated, returns 0. Amortized O(1).\n12.voidordered_free (void*const chunk);\nSame as abo ve, but is order -preserving.\nNote that chunk may not be 0. O(N) with respect to the size of the free list. chunk must ha ve been pre viously returned by t.malloc()\nor t.ordered_malloc().\n13.voidfree(void*const chunks,constsize_type n);\nAssumes that chunk actually refers to a block of chunks.\n30Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/chunk must ha ve been pre viously returned by t.ordered_malloc(n) spanning n * partition_sz bytes. Deallocates each chunk in that\nblock. Note that chunk may not be 0. O(n).\n14.voidordered_free (void*const chunks,constsize_type n);\nAssumes that chunk actually refers to a block of chunks spanning n * partition_sz bytes; deallocates each chunk in that block.\nNote that chunk may not be 0. Order -preserving. O(N + n) where N is the size of the free list. chunk must ha ve been pre viously\nreturned by t.malloc() or t.ordered_malloc().\n15.boolis_from(void*const chunk)const;\nReturns: Returns true if chunk w as allocated from u or may be returned as the result of a future allocation from u. Returns\nfalse if chunk w as allocated from some other pool or may be returned as the result of a future allocation from some\nother pool. Otherwise, the return v alue is meaningless. Note that this function may not be used to reliably test random\npointer v alues.\nHeader < boost/pool/pool_alloc.hpp >\nC++ Standard Library compatible pool-based allocators.\nThis header pro vides tw o template types - pool_allocator and f ast_pool_allocator - that can be used for f ast and efficient memory\nallocation in conjunction with the C++ Standard Library containers.\nThese types both satisfy the Standard Allocator requirements [20.1.5] and the additional requirements in [20.1.5/4], so the y can be\nused with either Standard or user -supplied containers.\nIn addition, the f ast_pool_allocator also pro vides an additional allocation and an additional deallocation function:\nSemantic Equi valence Retur n Type Expr ession\nPoolAlloc::allocate(1) T * PoolAlloc::allocate()\nPoolAlloc::dealloc-\nate(p, 1)void PoolAlloc::dealloc-\nate(p)\nThe typedef user_allocator publishes the v alue of the UserAllocator template parameter .\nNotes\nIf the allocation functions run out of memory , they will thro w std::bad_alloc .\nThe underlying Pool type used by the allocators is accessible through the Singleton Pool Interf ace. The identifying tag used for\npool_allocator is pool_allocator_tag, and the tag used for f ast_pool_allocator is f ast_pool_allocator_tag. All template parameters of\nthe allocators (including implementation-specific ones) determine the type of the underlying Pool, with the e xception of the first\nparameter T, whose size is used instead.\nSince the size of T is used to determine the type of the underlying Pool, each allocator for dif ferent types of the same size will share\nthe same underlying pool. The tag class pre vents pools from being shared between pool_allocator and f ast_pool_allocator . For example,\non a system where sizeof(int) == sizeof(void *) , pool_allocator<int> and pool_allocator<void *> will both\nallocate/deallocate from/to the same pool.\nIf there is only one thread running before main() starts and after main() ends, then both allocators are completely thread-safe.\nCompiler and STL Notes\n31Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/A number of common STL libraries contain b ugs in their using of allocators. Specifically , they pass null pointers to the deallocate\nfunction, which is e xplicitly forbidden by the Standard [20.1.5 Table 32]. PoolAlloc will w ork around these libraries if it detects\nthem; currently , workarounds are in place for: Borland C++ (Builder and command-line compiler) with def ault (RogueW ave) library ,\nver. 5 and earlier , STLport (with an y compiler), v er. 4.0 and earlier .\nnamespace boost{\nstructpool_allocator_tag ;\ntemplate <typename T,typename UserAllocator ,typename Mutex,\nunsigned NextSize ,unsigned MaxSize >\nclasspool_allocator ;\ntemplate <typename UserAllocator ,typename Mutex,unsigned NextSize ,\nunsigned MaxSize >\nclasspool_allocator <void,UserAllocator ,Mutex,NextSize ,MaxSize>;\nstructfast_pool_allocator_tag ;\ntemplate <typename T,typename UserAllocator ,typename Mutex,\nunsigned NextSize ,unsigned MaxSize >\nclassfast_pool_allocator ;\ntemplate <typename UserAllocator ,typename Mutex,unsigned NextSize ,\nunsigned MaxSize >\nclassfast_pool_allocator <void,UserAllocator ,Mutex,NextSize ,MaxSize>;\n}\nStruct pool_allocator_ta g\nboost::pool_allocator_tag\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\nstructpool_allocator_tag {\n};\nDescription\nSimple tag type used by pool_allocator as an ar gument to the underlying singleton_pool .\nClass template pool_allocator\nboost::pool_allocator —A C++ Standard Library conforming allocator , based on an underlying pool.\n32Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/pool_alloc.hpp >\ntemplate <typename T,typename UserAllocator ,typename Mutex,\nunsigned NextSize ,unsigned MaxSize >\nclasspool_allocator {\npublic:\n// types\ntypedef T value_type ; // value_type of template ↵\nparameter T. \ntypedef UserAllocator user_allocator ;// allocator that defines ↵\nthe method that the underlying Pool will use to allocate memory from the system. \ntypedef Mutex mutex; // typedef mutex publishes ↵\nthe value of the template parameter Mutex. \ntypedef value_type * pointer;\ntypedef constvalue_type * const_pointer ;\ntypedef value_type & reference ;\ntypedef constvalue_type & const_reference ;\ntypedef pool<UserAllocator >::size_type size_type ;\ntypedef pool<UserAllocator >::difference_type difference_type ;\n// member classes/structs/unions\n// Nested class rebind allows for transformation from pool_allocator<T> to\n // pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\n// construct/copy/destruct\npool_allocator ();\ntemplate <typename U>\npool_allocator (constpool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >&);\n// public member functions\nbooloperator ==(constpool_allocator &)const;\nbooloperator !=(constpool_allocator &)const;\n// public static functions\nstaticpointer address(reference );\nstaticconst_pointer address(const_reference );\nstaticsize_type max_size ();\nstaticvoidconstruct (constpointer,constvalue_type &);\nstaticvoiddestroy(constpointer);\nstaticpointer allocate (constsize_type );\nstaticpointer allocate (constsize_type ,constvoid*);\nstaticvoiddeallocate (constpointer,constsize_type );\n// public data members\nstaticconstunsigned next_size ;// next_size publishes the values of the template parameter ↵\nNextSize. \n};\nDescription\nTemplate parameters for pool_allocator are defined as follo ws:\nTType of object to allocate/deallocate.\n33Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/UserAllocator . Defines the method that the underlying Pool will use to allocate memory from the system. See User Allocators for\ndetails.\nMutex Allows the user to determine the type of synchronization to be used on the underlying singleton_pool .\nNextSize The v alue of this parameter is passed to the underlying singleton_pool when it is created.\nMaxSize Limit on the maximum size used.\nNote\nThe underlying singleton_pool used by the this allocator constructs a pool instance that is ne ver fr eed. This means\nthat memory allocated by the allocator can be still used after main() has completed, b ut may mean that some memory\nchecking programs will complain about leaks.\npool_allocator pub lic construct/cop y/destruct\n1.pool_allocator ();\nResults in def ault construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global\ninitialization ( required to ensure construction of singleton_pool IFF an instance of this allocator is constructed during global\ninitialization. See tick et #2359 for a complete e xplanation at http://svn.boost.or g/trac/boost/tick et/2359 ) .\n2.template <typename U>\npool_allocator (constpool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >&);\nResults in the def ault construction of the underlying singleton_pool , this is required to ensure construction of singleton_pool\nIFF an instance of this allocator is constructed during global initialization. See tick et #2359 for a complete e xplanation at ht-\ntp://svn.boost.or g/trac/boost/tick et/2359 .\npool_allocator pub lic member functions\n1.booloperator ==(constpool_allocator &)const;\n2.booloperator !=(constpool_allocator &)const;\npool_allocator pub lic static functions\n1.staticpointer address(reference r);\n2.staticconst_pointer address(const_reference s);\n3.staticsize_type max_size ();\n4.staticvoidconstruct (constpointer ptr,constvalue_type & t);\n34Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/5.staticvoiddestroy(constpointer ptr);\n6.staticpointer allocate (constsize_type n);\n7.staticpointer allocate (constsize_type n,constvoid* const);\nallocate n bytes\nParameters: nbytes to allocate.\n8.staticvoiddeallocate (constpointer ptr,constsize_type n);\nDeallocate n bytes from ptr\nParameters: n number of bytes to deallocate.\nptr location to deallocate from.\nStruct template rebind\nboost::pool_allocator::rebind — Nested class rebind allo ws for transformation from pool_allocator<T> to pool_allocator<U>.\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\n// Nested class rebind allows for transformation from pool_allocator<T> to\n// pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\nDescription\nNested class rebind allo ws for transformation from pool_allocator<T> to pool_allocator<U> via the member typedef other .\nSpecializations\n•Class template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>\nClass template pool_allocator<v oid, UserAllocator , Mute x, NextSiz e, MaxSiz e>\nboost::pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize> — Specialization of pool_allocator<v oid>.\n35Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/pool_alloc.hpp >\ntemplate <typename UserAllocator ,typename Mutex,unsigned NextSize ,\nunsigned MaxSize >\nclasspool_allocator <void,UserAllocator ,Mutex,NextSize ,MaxSize>{\npublic:\n// types\ntypedef void* pointer;\ntypedef constvoid*const_pointer ;\ntypedef void value_type ;\n// member classes/structs/unions\n// Nested class rebind allows for transformation from pool_allocator<T> to\n // pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\n};\nDescription\nSpecialization of pool_allocator for type v oid: required by the standard to mak e this a conforming allocator type.\nStruct template rebind\nboost::pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>::rebind — Nested class rebind allo ws for transformation\nfrom pool_allocator<T> to pool_allocator<U>.\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\n// Nested class rebind allows for transformation from pool_allocator<T> to\n// pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\nDescription\nNested class rebind allo ws for transformation from pool_allocator<T> to pool_allocator<U> via the member typedef other .\nStruct fast_pool_allocator_ta g\nboost::f ast_pool_allocator_tag —Simple tag type used by fast_pool_allocator as a template parameter to the underlying singleton_pool .\n36Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/pool_alloc.hpp >\nstructfast_pool_allocator_tag {\n};\nClass template fast_pool_allocator\nboost::f ast_pool_allocator —A C++ Standard Library conforming allocator geared to wards allocating single chunks.\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\ntemplate <typename T,typename UserAllocator ,typename Mutex,\nunsigned NextSize ,unsigned MaxSize >\nclassfast_pool_allocator {\npublic:\n// types\ntypedef T value_type ;\ntypedef UserAllocator user_allocator ;\ntypedef Mutex mutex;\ntypedef value_type * pointer;\ntypedef constvalue_type * const_pointer ;\ntypedef value_type & reference ;\ntypedef constvalue_type & const_reference ;\ntypedef pool<UserAllocator >::size_type size_type ;\ntypedef pool<UserAllocator >::difference_type difference_type ;\n// member classes/structs/unions\n// Nested class rebind allows for transformation from fast_pool_allocator<T>\n // to fast_pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef fast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\n// construct/copy/destruct\nfast_pool_allocator ();\ntemplate <typename U>\nfast_pool_allocator (constfast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >&);\n// public member functions\nvoidconstruct (constpointer,constvalue_type &);\nvoiddestroy(constpointer);\nbooloperator ==(constfast_pool_allocator &)const;\nbooloperator !=(constfast_pool_allocator &)const;\n// public static functions\nstaticpointer address(reference );\nstaticconst_pointer address(const_reference );\nstaticsize_type max_size ();\nstaticpointer allocate (constsize_type );\nstaticpointer allocate (constsize_type ,constvoid*);\nstaticpointer allocate ();\n37Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/staticvoiddeallocate (constpointer,constsize_type );\nstaticvoiddeallocate (constpointer);\n// public data members\nstaticconstunsigned next_size ;\n};\nDescription\nWhile class template pool_allocator is a more general-purpose solution geared to wards efficiently servicing requests for an y\nnumber of contiguous chunks, fast_pool_allocator is also a general-purpose solution, b ut is geared to wards efficiently servicing\nrequests for one chunk at a time; it will w ork for contiguous chunks, b ut not as well as pool_allocator .\nIf you are seriously concerned about performance, use fast_pool_allocator when dealing with containers such as std::list ,\nand use pool_allocator when dealing with containers such as std::vector .\nThe template parameters are defined as follo ws:\nTType of object to allocate/deallocate.\nUserAllocator . Defines the method that the underlying Pool will use to allocate memory from the system. See User Allocators for\ndetails.\nMutex Allows the user to determine the type of synchronization to be used on the underlying singleton_pool .\nNextSize The v alue of this parameter is passed to the underlying Pool when it is created.\nMaxSize Limit on the maximum size used.\nNote\nThe underlying singleton_pool used by the this allocator constructs a pool instance that is ne ver fr eed. This means\nthat memory allocated by the allocator can be still used after main() has completed, b ut may mean that some memory\nchecking programs will complain about leaks.\nfast_pool_allocator pub lic construct/cop y/destruct\n1.fast_pool_allocator ();\nEnsures construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global initializ-\nation. See tick et #2359 for a complete e xplanation at http://svn.boost.or g/trac/boost/tick et/2359 .\n2.template <typename U>\nfast_pool_allocator (constfast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize\n>&);\nEnsures construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global initializ-\nation. See tick et #2359 for a complete e xplanation at http://svn.boost.or g/trac/boost/tick et/2359 .\nfast_pool_allocator pub lic member functions\n1.voidconstruct (constpointer ptr,constvalue_type & t);\n2.voiddestroy(constpointer ptr);\n38Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Destro y ptr using destructor .\n3.booloperator ==(constfast_pool_allocator &)const;\n4.booloperator !=(constfast_pool_allocator &)const;\nfast_pool_allocator pub lic static functions\n1.staticpointer address(reference r);\n2.staticconst_pointer address(const_reference s);\n3.staticsize_type max_size ();\n4.staticpointer allocate (constsize_type n);\n5.staticpointer allocate (constsize_type n,constvoid* const);\nAllocate memory .\n6.staticpointer allocate ();\nAllocate memory .\n7.staticvoiddeallocate (constpointer ptr,constsize_type n);\nDeallocate memory .\n8.staticvoiddeallocate (constpointer ptr);\ndeallocate/free\nStruct template rebind\nboost::f ast_pool_allocator::rebind — Nested class rebind allo ws for transformation from f ast_pool_allocator<T> to f ast_pool_alloc-\nator<U>.\n39Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/pool_alloc.hpp >\n// Nested class rebind allows for transformation from fast_pool_allocator<T>\n// to fast_pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef fast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\nDescription\nNested class rebind allo ws for transformation from f ast_pool_allocator<T> to f ast_pool_allocator<U> via the member typedef other .\nSpecializations\n•Class template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>\nClass template fast_pool_allocator<v oid, UserAllocator , Mute x, NextSiz e,\nMaxSiz e>\nboost::f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize> — Specialization of f ast_pool_allocator<v oid>.\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\ntemplate <typename UserAllocator ,typename Mutex,unsigned NextSize ,\nunsigned MaxSize >\nclassfast_pool_allocator <void,UserAllocator ,Mutex,NextSize ,MaxSize>{\npublic:\n// types\ntypedef void* pointer;\ntypedef constvoid*const_pointer ;\ntypedef void value_type ;\n// member classes/structs/unions\n// Nested class rebind allows for transformation from fast_pool_allocator<T>\n // to fast_pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef fast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\n};\nDescription\nSpecialization of f ast_pool_allocator<v oid> required to mak e the allocator standard-conforming.\n40Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Struct template rebind\nboost::f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>::rebind — Nested class rebind allo ws for transformation\nfrom f ast_pool_allocator<T> to f ast_pool_allocator<U>.\nSynopsis\n// In header: < boost/pool/pool_alloc.hpp >\n// Nested class rebind allows for transformation from fast_pool_allocator<T>\n// to fast_pool_allocator<U>.\ntemplate <typename U>\nstructrebind{\n// types\ntypedef fast_pool_allocator <U,UserAllocator ,Mutex,NextSize ,MaxSize >other;\n};\nDescription\nNested class rebind allo ws for transformation from f ast_pool_allocator<T> to f ast_pool_allocator<U> via the member typedef other .\nHeader < boost/pool/poolfwd.hpp >\nForward declarations of all public (non-implemention) classes.\nHeader < boost/pool/simple_segregated_stora ge.hpp >\nSimple Se gregated Storage.\nA simple se gregated storage implementation: simple se gregated storage is the basic idea behind the Boost Pool library . Simple se-\ngregated storage is the simplest, and probably the f astest, memory allocation/deallocation algorithm. It be gins by partitioning a\nmemory block into fix ed-size chunks. Where the block comes from is not important until implementation time. A Pool is some object\nthat uses Simple Se gregated Storage in this f ashion.\nBOOST_POOL_VALIDATE_INTERNALS\nnamespace boost{\ntemplate <typename SizeType >classsimple_segregated_storage ;\n}\nClass template simple_segregated_stora ge\nboost::simple_se gregated_storage —Simple Se gregated Storage is the simplest, and probably the f astest, memory allocation/deal-\nlocation algorithm. It is responsible for partitioning a memory block into fix ed-size chunks: where the block comes from is determined\nby the client of the class.\n41Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/simple_segregated_storage.hpp >\ntemplate <typename SizeType >\nclasssimple_segregated_storage {\npublic:\n// types\ntypedef SizeType size_type ;\n// construct/copy/destruct\nsimple_segregated_storage (constsimple_segregated_storage &);\nsimple_segregated_storage ();\n simple_segregated_storage& operator =(constsimple_segregated_storage &);\n// private static functions\nstaticvoid*try_malloc_n (void*&,size_type ,size_type );\n// protected member functions\nvoid*find_prev (void*);\n// protected static functions\nstaticvoid*&nextof(void*const);\n// public member functions\nvoidadd_block (void*const,constsize_type ,constsize_type );\nvoidadd_ordered_block (void*const,constsize_type ,constsize_type );\nboolempty()const;\nvoid*malloc();\nvoidfree(void*const);\nvoidordered_free (void*const);\nvoid*malloc_n (size_type ,size_type );\nvoidfree_n(void*const,constsize_type ,constsize_type );\nvoidordered_free_n (void*const,constsize_type ,constsize_type );\n// public static functions\nstaticvoid*segregate (void*,size_type ,size_type ,void*=0);\n};\nDescription\nTemplate class simple_se gregated_storage controls access to a free list of memory chunks. Please note that this is a v ery simple\nclass, with preconditions on almost all its functions. It is intended to be the f astest and smallest possible quick memory allocator -\ne.g., something to use in embedded systems. This class dele gates man y difficult preconditions to the user (i.e., alignment issues).\nAn object of type simple_se gregated_storage<SizeT ype> is empty if its free list is empty . If it is not empty , then it is ordered if its\nfree list is ordered. A free list is ordered if repeated calls to malloc() will result in a constantly-increasing sequence of v alues, as\ndetermined by std::less<void *> . A member function is order-preserving if the free list maintains its order orientation (that is,\nan ordered free list is still ordered after the member function call).\nsimple_segregated_storage pub lic construct/cop y/destruct\n1.simple_segregated_storage (constsimple_segregated_storage &);\n2.simple_segregated_storage ();\nConstruct empty storage area.\nPostconditions: empty()\n42Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/3.simple_segregated_storage& operator =(constsimple_segregated_storage &);\nsimple_segregated_storage priv ate static functions\n1.staticvoid*\ntry_malloc_n (void*& start,size_type n,size_type partition_size );\nRequires: (n > 0), (start != 0), (ne xtof(start) != 0)\nPostconditions: (start != 0) The function attempts to find n contiguous chunks of size partition_size in the free list,\nstarting at start. If it succeds, it returns the last chunk in that contiguous sequence, so that the sequence\nis kno wn by [start, {retv al}] If it f ails, it does do either because it's at the end of the free list or hits a\nnon-contiguous chunk. In either case, it will return 0, and set start to the last considered chunk. You are\nat the end of the free list if ne xtof(start) == 0. Otherwise, start points to the last chunk in the contiguous\nsequence, and ne xtof(start) points to the first chunk in the ne xt contiguous sequence (assuming an ordered\nfree list).\nsimple_segregated_storage protected member functions\n1.void*find_prev (void* ptr);\nTraverses the free list referred to by \"first\", and returns the iterator pre vious to where \"ptr\" w ould go if it w as in the free list. Returns\n0 if \"ptr\" w ould go at the be ginning of the free list (i.e., before \"first\").\nNote\nNote that this function finds the location pre vious to where ptr w ould go if it w as in the free list. It does not find\nthe entry in the free list before ptr (unless ptr is already in the free list). Specifically , find_pre v(0) will return 0,\nnot the last entry in the free list.\nReturns: location pre vious to where ptr w ould go if it w as in the free list.\nsimple_segregated_storage protected static functions\n1.staticvoid*&nextof(void*const ptr);\nThe return v alue is just *ptr cast to the appropriate type. ptr must not be 0. (F or the sak e of code readability :)\nAs an e xample, let us assume that we w ant to truncate the free list after the first chunk. That is, we w ant to set *first to 0; this\nwill result in a free list with only one entry . The normal w ay to do this is to first cast first to a pointer to a pointer to v oid, and\nthen dereference and assign (*static_cast<v oid **>(first) = 0;). This can be done more easily through the use of this con venience\nfunction (ne xtof(first) = 0;).\nReturns: dereferenced pointer .\nsimple_segregated_storage pub lic member functions\n1.voidadd_block (void*const block,constsize_type nsz,\nconstsize_type npartition_sz );\nAdd block Se gregate this block and mer ge its free list into the free list referred to by \"first\".\nRequires: Same as se gregate.\nPostconditions: !empty()\n43Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/2.voidadd_ordered_block (void*const block,constsize_type nsz,\nconstsize_type npartition_sz );\nadd block (ordered into list) This (slo wer) v ersion of add_block se gregates the block and mer ges its free list into our free list in\nthe proper order .\n3.boolempty()const;\nReturns: true only if simple_se gregated_storage is empty .\n4.void*malloc();\nCreate a chunk.\nRequires: !empty() Increment the \"first\" pointer to point to the ne xt chunk.\n5.voidfree(void*const chunk);\nFree a chunk.\nRequires: chunk w as pre viously returned from a malloc() referring to the same free list.\nPostconditions: !empty()\n6.voidordered_free (void*const chunk);\nThis (slo wer) implementation of 'free' places the memory back in the list in its proper order .\nRequires: chunk w as pre viously returned from a malloc() referring to the same free list\nPostconditions: !empty().\n7.void*malloc_n (size_type n,size_type partition_size );\nAttempts to find a contiguous sequence of n partition_sz-sized chunks. If found, remo ves them all from the free list and returns\na pointer to the first. If not found, returns 0. It is strongly recommended (b ut not required) that the free list be ordered, as this al-\ngorithm will f ail to find a contiguous sequence unless it is contiguous in the free list as well. Order -preserving. O(N) with respect\nto the size of the free list.\n8.voidfree_n(void*const chunks,constsize_type n,\nconstsize_type partition_size );\nNote\nIf you're allocating/deallocating n a lot, you should be using an ordered pool.\nRequires: chunks w as pre viously allocated from *this with the same v alues for n and partition_size.\nPostconditions: !empty()\n9.voidordered_free_n (void*const chunks,constsize_type n,\nconstsize_type partition_size );\nFree n chunks from order list.\nRequires: chunks w as pre viously allocated from *this with the same v alues for n and partition_size.\nn should not be zero (n == 0 has no ef fect).\n44Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/simple_segregated_storage pub lic static functions\n1.staticvoid*\nsegregate (void* block,size_type nsz,size_type npartition_sz ,\nvoid* end =0);\nSegregate block into chunks.\nRequires: npartition_sz >= sizeof(v oid *)\nnpartition_sz = sizeof(v oid *) * i, for some inte ger i\nnsz >= npartition_sz\nBlock is properly aligned for an array of object of size npartition_sz and array of v oid *. The requirements abo ve\nguarantee that an y pointer to a chunk (which is a pointer to an element in an array of npartition_sz) may be cast\nto void **.\nMacr o BOOST_POOL_V ALID ATE_INTERNALS\nBOOST_POOL_V ALID ATE_INTERN ALS\nSynopsis\n// In header: < boost/pool/simple_segregated_storage.hpp >\nBOOST_POOL_VALIDATE_INTERNALS\nHeader < boost/pool/singleton_pool.hpp >\nThe singleton_pool class allo ws other pool interf aces for types of the same size to share the same underlying pool.\nHeader singleton_pool.hpp pro vides a template class singleton_pool , which pro vides access to a pool as a singleton object.\nnamespace boost{\ntemplate <typename Tag,unsigned RequestedSize ,typename UserAllocator ,\ntypename Mutex,unsigned NextSize ,unsigned MaxSize >\nclasssingleton_pool ;\n}\nClass template singleton_pool\nboost::singleton_pool\n45Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/singleton_pool.hpp >\ntemplate <typename Tag,unsigned RequestedSize ,typename UserAllocator ,\ntypename Mutex,unsigned NextSize ,unsigned MaxSize >\nclasssingleton_pool {\npublic:\n// types\ntypedef Tag tag;\ntypedef Mutex mutex; // The type of mutex used to ↵\nsynchonise access to this pool (default details::pool::default_mutex ). \ntypedef UserAllocator user_allocator ;// The user-allocator used ↵\nby this pool, default = default_user_allocator_new_delete . \ntypedef pool<UserAllocator >::size_type size_type ; // size_type of user allocator. \ntypedef pool<UserAllocator >::difference_type difference_type ;// difference_type of user ↵\nallocator. \n// member classes/structs/unions\nstructobject_creator {\n// construct/copy/destruct\nobject_creator ();\n// public member functions\nvoiddo_nothing ()const;\n};\n// construct/copy/destruct\nsingleton_pool ();\n// public static functions\nstaticvoid*malloc();\nstaticvoid*ordered_malloc ();\nstaticvoid*ordered_malloc (constsize_type );\nstaticboolis_from(void*const);\nstaticvoidfree(void*const);\nstaticvoidordered_free (void*const);\nstaticvoidfree(void*const,constsize_type );\nstaticvoidordered_free (void*const,constsize_type );\nstaticboolrelease_memory ();\nstaticboolpurge_memory ();\n// private static functions\nstaticpool_type &get_pool ();\n// public data members\nstaticconstunsigned requested_size ;// The size of each chunk allocated by this pool. \nstaticconstunsigned next_size ;// The number of chunks to allocate on the first allocation. \nstaticpool<UserAllocator >p;// For exposition only! \n};\nDescription\nThe singleton_pool class allo ws other pool interf aces for types of the same size to share the same pool. Template parameters are as\nfollows:\nTag User -specified type to uniquely identify this pool: allo ws dif ferent unbounded sets of singleton pools to e xist.\nRequestedSize The size of each chunk returned by member function malloc() .\nUserAllocator User allocator , default = default_user_allocator_ne w_delete .\n46Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Mutex This class is the type of mute x to use to protect simultaneous access to the underlying Pool. Can be an y Boost.Thread Mute x\ntype or boost::details::pool::null_mutex . It is e xposed so that users may declare some singleton pools normally (i.e., with\nsynchronization), b ut some singleton pools without synchronization (by specifying boost::details::pool::null_mutex ) for\nefficienc y reasons. The member typedef mutex exposes the v alue of this template parameter . The def ault for this parameter is\nboost::details::pool::def ault_mute x which is a synon ym for either boost::details::pool::null_mutex (when threading support\nis turned of f in the compiler (so BOOST_HAS_THREADS is not set), or threading support has ben e xplicitly disabled with\nBOOST_DISABLE_THREADS (Boost-wide disabling of threads) or BOOST_POOL_NO_MT (this library only)) or for\nboost::mutex (when threading support is enabled in the compiler).\nNextSize The v alue of this parameter is passed to the underlying Pool when it is created and specifies the number of chunks to allocate\nin the first allocation request (def aults to 32). The member typedef static const value next_size exposes the v alue of this\ntemplate parameter .\nMaxSize The v alue of this parameter is passed to the underlying Pool when it is created and specifies the maximum number of chunks\nto allocate in an y single allocation request (def aults to 0).\nNotes:\nThe underlying pool p referenced by the static functions in singleton_pool is actually declared in a w ay that is:\n1 Thread-safe if there is only one thread running before main() be gins and after main() ends -- all of the static functions of\nsingleton_pool synchronize their access to p.\n2 Guaranteed to be constructed before it is used -- thus, the simple static object in the synopsis abo ve would actually be an incorrect\nimplementation. The actual implementation to guarantee this is considerably more complicated.\n3 Note too that a dif ferent underlying pool p e xists for each dif ferent set of template parameters, including implementation-specific\nones.\n4 The underlying pool is constructed \"as if\" by:\npool<UserAllocator> p(RequestedSize, Ne xtSize, MaxSize);\nNote\nThe underlying pool constructed by the singleton is ne ver fr eed. This means that memory allocated by a\nsingleton_pool can be still used after main() has completed, b ut may mean that some memory checking programs\nwill complain about leaks from singleton_pool .\nsingleton_pool pub lic types\n1.typedef Tagtag;\nThe Tag template parameter uniquely identifies this pool and allo ws dif ferent unbounded sets of singleton pools to e xist. F or ex-\nample, the pool allocators use tw o tag classes to ensure that the tw o dif ferent allocator types ne ver share the same underlying\nsingleton pool. Tag is ne ver actually used by singleton_pool .\nsingleton_pool pub lic construct/cop y/destruct\n1.singleton_pool ();\nsingleton_pool pub lic static functions\n1.staticvoid*malloc();\nEquivalent to SingletonPool::p.malloc(); synchronized.\n47Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/2.staticvoid*ordered_malloc ();\nEquivalent to SingletonPool::p.ordered_malloc(); synchronized.\n3.staticvoid*ordered_malloc (constsize_type n);\nEquivalent to SingletonPool::p.ordered_malloc(n); synchronized.\n4.staticboolis_from(void*const ptr);\nEquivalent to SingletonPool::p.is_from(chunk); synchronized.\nReturns: true if chunk is from SingletonPool::is_from(chunk)\n5.staticvoidfree(void*const ptr);\nEquivalent to SingletonPool::p.free(chunk); synchronized.\n6.staticvoidordered_free (void*const ptr);\nEquivalent to SingletonPool::p.ordered_free(chunk); synchronized.\n7.staticvoidfree(void*const ptr,constsize_type n);\nEquivalent to SingletonPool::p.free(chunk, n); synchronized.\n8.staticvoidordered_free (void*const ptr,constsize_type n);\nEquivalent to SingletonPool::p.ordered_free(chunk, n); synchronized.\n9.staticboolrelease_memory ();\nEquivalent to SingletonPool::p.release_memory(); synchronized.\n10.staticboolpurge_memory ();\nEquivalent to SingletonPool::p.pur ge_memory(); synchronized.\nsingleton_pool priv ate static functions\n1.staticpool_type &get_pool ();\nStruct object_creator\nboost::singleton_pool::object_creator\n48Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Synopsis\n// In header: < boost/pool/singleton_pool.hpp >\nstructobject_creator {\n// construct/copy/destruct\nobject_creator ();\n// public member functions\nvoiddo_nothing ()const;\n};\nDescription\nobject_creator pub lic construct/cop y/destruct\n1.object_creator ();\nobject_creator pub lic member functions\n1.voiddo_nothing ()const;\n49Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Appendices\nAppendix A: Histor y\nVersion 2.0.0, January 11, 2011\nDocumentation and testing r evision\nFeatur es:\n•Fix issues 1252 , 4960 , 5526 , 5700 , 2696 .\n•Documentation con verted and re written and re vised by P aul A. Bristo w using Quickbook, Doxygen, for html and pdf, based on\nStephen Cleary's html v ersion, Re vised 05 December , 2006.\nThis used Opera 11.0, and html_to_quickbook .css as a special display format. On the Opera full taskbar (chose enable full\ntaskbar ) View, Style, Manage modes, Display .\nChoose add \\boost -sandbox \\boost_docs \\trunk \\doc\\style \\html \\conversion \\html_to_quickbook .css to My Style\nSheet. Html pages are no w displayed as Quickbook and can be copied and pasted into quickbook files using your f avored te xt editor\nfor Quickbook.\nVersion 1.0.0, January 1, 2000\nFirst release\nAppendix B: FAQ\nWhy should I use P ool?\nUsing Pools gi ves you more control o ver ho w memory is used in your program. F or example, you could ha ve a situation where you\nwant to allocate a b unch of small objects at one point, and then reach a point in your program where none of them are needed an y\nmore. Using pool interf aces, you can choose to run their destructors or just drop them of f into obli vion; the pool interf ace will\nguarantee that there are no system memory leaks.\nWhen should I use P ool?\nPools are generally used when there is a lot of allocation and deallocation of small objects. Another common usage is the situation\nabove, where man y objects may be dropped out of memory .\nIn general, use Pools when you need a more efficient w ay to do unusual memory control.\nAppendix C: Acknowledg ements\nMany, man y thanks to the Boost peers, notably Jef f Garland, Beman Da wes, Ed Bre y, Gary Po well, Peter Dimo v, and Jens Maurer\nfor pro viding helpful suggestions!\nAppendix D: Tests\nSee folder boost/libs/pool/test/.\nAppendix E: Tickets\nReport and vie w bugs and features by adding a tick et at Boost.T rac.\n50Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Existing open tick ets for this library alone can be vie wed here. Existing tick ets for this library - including closed ones - can be vie wed\nhere.\nAppendix F: Other Implementations\nPool allocators are found in man y programming languages, and in man y variations. The be ginnings of man y implementations may\nbe found in common programming literature; some of these are gi ven belo w. Note that none of these are complete implementations\nof a Pool; most of these lea ve some aspects of a Pool as a user e xercise. Ho wever, in each case, e ven though some aspects are\nmissing, these e xamples use the same underlying concept of a Simple Se gregated Storage described in this document.\n1.The C++ Pr ogramming Langua ge, 3rd ed., by Bjarne Stroustrup, Section 19.4.2. Missing aspects:\n•Not portable.\n•Cannot handle allocations of arbitrary numbers of objects (this w as left as an e xercise).\n•Not thread-safe.\n•Suffers from the static initialization problem.\n2.Micr oC/OS-II: The Real-T ime K ernel , by Jean J. Labrosse, Chapter 7 and Appendix B.04.\n•An e xample of the Simple Se gregated Storage scheme at w ork in the internals of an actual OS.\n•Missing aspects:\n•Not portable (though this is OK, since it's part of its o wn OS).\n•Cannot handle allocations of arbitrary numbers of blocks (which is also OK, since this feature is not needed).\n•Requires non-intuiti ve user code to create and destro y the Pool.\n3.Efficient C++: P erformance Pr ogramming Techniques , by Do v Bulka and Da vid Mayhe w, Chapters 6 and 7.\n•This is a good e xample of iterati vely de veloping a Pool solutio.\n•however, their premise (that the system-supplied allocation mechanism is hopelessly inefficient) is fla wed on e very system\nI've tested on.\n•Run their timings on your system before you accept their conclusions.\n•Missing aspect: Requires non-intuiti ve user code to create and destro y the Pool.\n4.Advanced C++: Pr ogramming Styles and Idioms , by James O. Coplien, Section 3.6.\n•Has e xamples of both static and dynamic pooling, b ut missing aspects:\n•Not thread-safe.\n•The static pooling e xample is not portable.\nAppendix G: References\n1.Doug Lea, A Memory Allocator . See http://gee.cs.oswe go.edu/dl/html/malloc.html\n2.Paul R. Wilson, Mark S. Johnstone, Michael Neely , and Da vid Boles, Dynamic Stor age Allocation: A Surve y and Critical Re view\nin International Workshop on Memory Management, September 1995, pg. 28, 36. See ftp://ftp.cs.ute xas.edu/pub/g arbage/allocsrv .ps\n51Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Appendix H: Future plans\nAnother pool interf ace will be written: a base class for per -class pool allocation.\nThis \"pool_base\" interf ace will be Singleton Usage with Exceptions, and b uilt on the singleton_pool interf ace.\n52Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Indexes\nFunction Inde x\nA\naddress\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 34\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\npool_allocator , 8\nadd_block\nClass template simple_se gregated_storage, 42, 43\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nadd_ordered_block\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nallocate\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 35\npool_allocator , 8\nC\nconstruct\nClass template f ast_pool_allocator , 37, 38\nClass template object_pool, 22, 24\nClass template pool_allocator , 33, 34\nObject_pool, 6\npool_allocator , 8\nD\ndeallocate\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 35\npool_allocator , 8\ndestro y\nClass template f ast_pool_allocator , 37, 38\nClass template object_pool, 22, 24\nClass template pool_allocator , 33, 35\nObject_pool, 6\npool_allocator , 8\nF\nfind_pre v\nClass template simple_se gregated_storage, 42, 43\nfree\nClass template object_pool, 22, 23\nClass template pool, 27, 30\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 48\nObject_pool, 6\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25, 26\n53Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/free_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nG\nget_pool\nClass template singleton_pool, 46, 48\nI\nis_from\nClass template object_pool, 22, 24\nClass template pool, 27, 29, 31\nClass template singleton_pool, 46, 48\nObject_pool, 6\npool, 4\nSingleton_pool, 7\nM\nmain\nClass template f ast_pool_allocator , 38\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nHeader < boost/pool/pool_alloc.hpp >, 31\nSingleton_pool, 7\nmalloc\nClass template object_pool, 22, 23\nClass template pool, 27, 28, 30, 31\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 47\nObject_pool, 6\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25, 26\nmalloc_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nmalloc_need_resize\nClass template pool, 27, 28\nmax_size\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 34\npool_allocator , 8\nN\nnextof\nClass template object_pool, 22, 23\nClass template pool, 27, 29\nClass template simple_se gregated_storage, 42, 43\nO\nordered_free\nClass template pool, 27, 30, 31\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 48\n54Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/pool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nordered_free_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nordered_malloc\nClass template pool, 27, 30\nClass template singleton_pool, 46, 48\npool, 4\nSingleton_pool, 7\nordered_malloc_need_resize\nClass template pool, 27, 28\nP\npurge_memory\nClass template pool, 27, 29\nClass template singleton_pool, 46, 48\npool, 4\nSingleton_pool, 7\nR\nrelease_memory\nClass template pool, 27, 29\nClass template singleton_pool, 46, 48\npool, 4\nSingleton_pool, 7\nS\nsegregate\nClass template simple_se gregated_storage, 42, 45\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nset_max_size\nClass template pool, 27, 30\nset_ne xt_size\nClass template object_pool, 22, 25\nClass template pool, 27, 29\nsizeof\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/pool_alloc.hpp >, 31\nHow Contiguous Chunks are Handled, 15\nT\ntry_malloc_n\nClass template simple_se gregated_storage, 42, 43\nClass Inde x\nD\ndefault_user_allocator_malloc_free\npool, 4\nStruct def ault_user_allocator_malloc_free, 26\ndefault_user_allocator_ne w_delete\npool, 4\nStruct def ault_user_allocator_ne w_delete, 25\n55Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/F\nfast_pool_allocator\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\npool_allocator , 8\nStruct template rebind, 40, 41\nfast_pool_allocator_tag\npool_allocator , 8\nStruct f ast_pool_allocator_tag, 37\nO\nobject_creator\nClass template singleton_pool, 46\nStruct object_creator , 49\nobject_pool\nClass template object_pool, 22, 23\nObject_pool, 6\nP\npool\nClass template object_pool, 22\nClass template pool, 27\npool, 4\npool_allocator\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nStruct template rebind, 35, 36\npool_allocator_tag\npool_allocator , 8\nStruct pool_allocator_tag, 32\nR\nrebind\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nStruct template rebind, 35, 36, 40, 41\nS\nsimple_se gregated_storage\nClass template pool, 27\nClass template simple_se gregated_storage, 42\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nsingleton_pool\nClass template singleton_pool, 45, 46, 47, 48\nSingleton_pool, 7\nTypedef Inde x\nC\nconst_pointer\nClass template f ast_pool_allocator , 37\n56Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Class template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nconst_reference\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\npool_allocator , 8\nD\ndifference_type\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nObject_pool, 6\npool, 4\npool_allocator , 8\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nE\nelement_type\nClass template object_pool, 22\nObject_pool, 6\nM\nmute x\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nO\nother\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nStruct template rebind, 35, 36, 40, 41\nP\npointer\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nR\nreference\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\npool_allocator , 8\n57Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/S\nsize_type\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template simple_se gregated_storage, 42\nClass template singleton_pool, 46\nObject_pool, 6\npool, 4\npool_allocator , 8\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nT\ntag\nClass template singleton_pool, 46, 47\nSingleton_pool, 7\nU\nuser_allocator\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nObject_pool, 6\npool, 4\npool_allocator , 8\nSingleton_pool, 7\nV\nvalue_type\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nIndex\nA\naddress\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 34\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\npool_allocator , 8\nadd_block\nClass template simple_se gregated_storage, 42, 43\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nadd_ordered_block\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nalignment\n58Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Class template pool, 26\nClass template simple_se gregated_storage, 42\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/pool.hpp >, 25\nHow Contiguous Chunks are Handled, 15\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nallocate\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 35\npool_allocator , 8\nallocation\nAllocation and Deallocation, 16\nAppendix B: F AQ, 50\nAppendix F: Other Implementations, 51\nAppendix G: References, 51\nAppendix H: Future plans, 52\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template object_pool, 22, 24\nClass template pool, 27, 29, 31\nClass template simple_se gregated_storage, 41\nClass template singleton_pool, 46\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/object_pool.hpp >, 22\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHow Contiguous Chunks are Handled, 15\nIntroduction, 2\nObject_pool, 6\npool_allocator , 8\nSimple Se gregated Storage, 12\nAllocation and Deallocation\nallocation, 16\nblock, 16\nchunk, 16\ndeallocation, 16\nmalloc, 16\nordered, 16\nsize, 16\nAppendix B: F AQ\nallocation, 50\ndeallocation, 50\ninterf ace, 50\nmemory , 50\nobjects, 50\nAppendix F: Other Implementations\nallocation, 51\nblock, 51\nconcepts, 51\nobjects, 51\nportable, 51\nsegregated, 51\nAppendix G: References\nallocation, 51\nmalloc, 51\nmemory , 51\nsegregated, 51\n59Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Appendix H: Future plans\nallocation, 52\ninterf ace, 52\nsingleton, 52\nsingleton_pool, 52\nautomatic\nClass template object_pool, 22\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/object_pool.hpp >, 22\nObject_pool, 6\nB\nBasic ideas behind pooling\nallocation, 10\nblock, 10\nchunk, 10\nheaders, 10\nmalloc, 10\nmemory , 10\nnew, 10\nobjects, 10\nordered, 10\nsegregated, 10\nsize, 10\nblock\nAllocation and Deallocation, 16\nAppendix F: Other Implementations, 51\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template object_pool, 23\nClass template pool, 28, 29, 30, 31\nClass template simple_se gregated_storage, 41, 43, 44, 45\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13, 14\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHow Contiguous Chunks are Handled, 15\npool, 4\nSegregation, 16\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 26\nSymbol Table, 16\nThe UserAllocator Concept, 21\nUserAllocator Requirements, 21\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one.\nallocation, 3\nblock, 3\nchunk, 3\nconcepts, 3\ninterf ace, 3\nmemory , 3\nobjects, 3\nordered, 3\nsingleton, 3\nBOOST_POOL_V ALID ATE_INTERN ALS\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nMacro BOOST_POOL_V ALID ATE_INTERN ALS, 45\n60Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/build\nInstallation, 3\nBuilding the Test Programs\njamfile, 3\nC\nchunk\nAllocation and Deallocation, 16\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template f ast_pool_allocator , 37, 38\nClass template object_pool, 23, 24, 25\nClass template pool, 26, 27, 28, 29, 30, 31\nClass template simple_se gregated_storage, 41, 42, 43, 44, 45\nClass template singleton_pool, 46, 48\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13, 14\nHeader < boost/pool/pool.hpp >, 25\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHow Contiguous Chunks are Handled, 15\nIntroduction, 2\nObject_pool, 6\npool, 4\nSegregation, 16\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nSymbol Table, 16\nThe UserAllocator Concept, 21\nClass template f ast_pool_allocator\naddress, 37, 39\nallocate, 37, 39\nchunk, 37, 38\nconstruct, 37, 38\nconst_pointer , 37\nconst_reference, 37\ndeallocate, 37, 39\ndestro y, 37, 38\ndifference_type, 37\nfast_pool_allocator , 37\nheaders, 37\nmain, 38\nmax_size, 37, 39\nmemory , 38, 39\nmute x, 37\nobjects, 38\nother , 37\npointer , 37\nrebind, 37\nreference, 37\nsingleton, 38\nsingleton_pool, 38\nsize, 37, 38, 39\nsize_type, 37\ntemplate, 37, 38, 40\nuser_allocator , 37\nvalue_type, 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>\n61Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/const_pointer , 40\nfast_pool_allocator , 40\nheaders, 40\nother , 40\npointer , 40\nrebind, 40\ntemplate, 40\nvalue_type, 40\nClass template object_pool\nallocation, 22, 24\nautomatic, 22\nblock, 23\nchunk, 23, 24, 25\nconstruct, 22, 24\ndestro y, 22, 24\ndifference_type, 22\nelement_type, 22\nfree, 22, 23\nheaders, 22\ninclude, 24\nis_from, 22, 24\nmalloc, 22, 23\nmemory , 22, 23, 24, 25\nnew, 23, 25\nnextof, 22, 23\nobjects, 22, 23, 24\nobject_pool, 22, 23\npool, 22\nsegregated, 23\nset_ne xt_size, 22, 25\nsize, 22, 23, 24, 25\nsize_type, 22\ntemplate, 22, 24\nuser_allocator , 22\nClass template pool\nalignment, 26\nallocation, 27, 29, 31\nblock, 28, 29, 30, 31\nchunk, 26, 27, 28, 29, 30, 31\ndifference_type, 27\nfree, 27, 30\nheaders, 27\nis_from, 27, 29, 31\nmalloc, 27, 28, 30, 31\nmalloc_need_resize, 27, 28\nmemory , 26, 27, 28, 29, 30\nnew, 28, 30\nnextof, 27, 29\nobjects, 27, 28, 29, 30\nordered, 27, 28, 29, 30, 31\nordered_free, 27, 30, 31\nordered_malloc, 27, 30\nordered_malloc_need_resize, 27, 28\npool, 27\npurge_memory , 27, 29\nrelease_memory , 27, 29\nsegregated, 27, 28, 29\nset_max_size, 27, 30\n62Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/set_ne xt_size, 27, 29\nsimple_se gregated_storage, 27\nsize, 27, 28, 29, 30, 31\nsize_type, 27\ntemplate, 26, 27\nuser_allocator , 27\nClass template pool_allocator\naddress, 33, 34\nallocate, 33, 35\nconstruct, 33, 34\nconst_pointer , 33\nconst_reference, 33\ndeallocate, 33, 35\ndestro y, 33, 35\ndifference_type, 33\nheaders, 33\nmain, 33\nmax_size, 33, 34\nmemory , 33\nmute x, 33\nobjects, 33\nother , 33\npointer , 33\npool_allocator , 33\nrebind, 33\nreference, 33\nsingleton, 33, 34\nsingleton_pool, 33, 34\nsize, 33, 34, 35\nsize_type, 33\ntemplate, 32, 33, 34, 35\nuser_allocator , 33\nvalue_type, 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>\nconst_pointer , 36\nheaders, 36\nother , 36\npointer , 36\npool_allocator , 36\nrebind, 36\ntemplate, 35, 36\nvalue_type, 36\nClass template simple_se gregated_storage\nadd_block, 42, 43\nadd_ordered_block, 42, 44\nalignment, 42\nallocation, 41\nblock, 41, 43, 44, 45\nchunk, 41, 42, 43, 44, 45\ndeallocation, 41\nfind_pre v, 42, 43\nfree, 42, 44\nfree_n, 42, 44\nheaders, 42\nmalloc, 42, 44\nmalloc_n, 42, 44\nmemory , 41, 42, 44\nnextof, 42, 43\n63Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/objects, 42, 45\nordered, 42, 43, 44\nordered_free, 42, 44\nordered_free_n, 42, 44\nsegregate, 42, 45\nsegregated, 41, 42, 43, 44, 45\nsimple_se gregated_storage, 42\nsize, 41, 42, 43, 44, 45\nsize_type, 42\ntemplate, 41, 42\ntry_malloc_n, 42, 43\nClass template singleton_pool\nallocation, 46\nchunk, 46, 48\ndifference_type, 46\nfree, 46, 48\nget_pool, 46, 48\nheaders, 46\ninterf ace, 46\nis_from, 46, 48\nmain, 46\nmalloc, 46, 47\nmemory , 46\nmute x, 46\nobjects, 46\nobject_creator , 46\nordered, 46, 48\nordered_free, 46, 48\nordered_malloc, 46, 48\npurge_memory , 46, 48\nrelease_memory , 46, 48\nsingleton, 45, 46, 47, 48\nsingleton_pool, 45, 46, 47, 48\nsize, 46, 48\nsize_type, 46\ntag, 46, 47\ntemplate, 45, 46, 47\nuser_allocator , 46\nconcepts\nAppendix F: Other Implementations, 51\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nDocumentation Naming and F ormatting Con ventions, 2\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nIntroduction, 2\nThe UserAllocator Concept, 21\nconstruct\nClass template f ast_pool_allocator , 37, 38\nClass template object_pool, 22, 24\nClass template pool_allocator , 33, 34\nObject_pool, 6\npool_allocator , 8\nConstructors, Destructors, and State\nnew, 16\nordered, 16\nconst_pointer\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\n64Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Class template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nconst_reference\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\npool_allocator , 8\nconventions\nDocumentation Naming and F ormatting Con ventions, 2\nD\ndeallocate\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 35\npool_allocator , 8\ndeallocation\nAllocation and Deallocation, 16\nAppendix B: F AQ, 50\nClass template simple_se gregated_storage, 41\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nIntroduction, 2\nSimple Se gregated Storage, 12\ndefault_user_allocator_malloc_free\npool, 4\nStruct def ault_user_allocator_malloc_free, 26\ndefault_user_allocator_ne w_delete\npool, 4\nStruct def ault_user_allocator_ne w_delete, 25\ndestro y\nClass template f ast_pool_allocator , 37, 38\nClass template object_pool, 22, 24\nClass template pool_allocator , 33, 35\nObject_pool, 6\npool_allocator , 8\ndifference_type\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nObject_pool, 6\npool, 4\npool_allocator , 8\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nDocumentation Naming and F ormatting Con ventions\nconcepts, 2\nconventions, 2\ninclude, 2\nnaming, 2\nobjects, 2\ntemplate, 2\nE\nelements\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\n65Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/element_type\nClass template object_pool, 22\nObject_pool, 6\nF\nfast_pool_allocator\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\npool_allocator , 8\nStruct template rebind, 40, 41\nfast_pool_allocator_tag\npool_allocator , 8\nStruct f ast_pool_allocator_tag, 37\nfind_pre v\nClass template simple_se gregated_storage, 42, 43\nfree\nClass template object_pool, 22, 23\nClass template pool, 27, 30\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 48\nObject_pool, 6\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25, 26\nfree_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nG\nget_pool\nClass template singleton_pool, 46, 48\nGuaranteeing Alignment - Ho w we guarantee alignment portably .\naddress, 13\nalignment, 13\nallocation, 13\nautomatic, 13\nblock, 13, 14\nchunk, 13, 14\nconcepts, 13\nelements, 13\nmemory , 13, 14\nnew, 13\nobjects, 13, 14\novervie w, 13\npadding, 13\nportable, 13\nsegregated, 13\nsize, 13, 14\nsizeof, 13\nH\nHeader < boost/pool/object_pool.hpp >\nallocation, 22\nautomatic, 22\nheaders, 22\n66Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/memory , 22\nobjects, 22\nobject_pool, 22\ntemplate, 22\nHeader < boost/pool/pool.hpp >\nalignment, 25\nchunk, 25\nheaders, 25\nmemory , 25\nsegregated, 25\ntemplate, 25\nHeader < boost/pool/poolfwd.hpp >\nheaders, 41\nHeader < boost/pool/pool_alloc.hpp >\nallocation, 31\ndeallocation, 31\nheaders, 31\ninterf ace, 31\nmain, 31\nmemory , 31\nsingleton, 31\nsize, 31\nsizeof, 31\ntemplate, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >\nallocation, 41\nblock, 41\nBOOST_POOL_V ALID ATE_INTERN ALS, 41\nchunk, 41\ndeallocation, 41\nheaders, 41\nmemory , 41\nobjects, 41\nsegregated, 41\nsize, 41\ntemplate, 41\nHeader < boost/pool/singleton_pool.hpp >\nheaders, 45\ninterf ace, 45\nobjects, 45\nsingleton, 45\nsingleton_pool, 45\nsize, 45\ntemplate, 45\nheaders\nBasic ideas behind pooling, 10\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\nClass template simple_se gregated_storage, 42\nClass template singleton_pool, 46\nHeader < boost/pool/object_pool.hpp >, 22\nHeader < boost/pool/pool.hpp >, 25\nHeader < boost/pool/poolfwd.hpp >, 41\nHeader < boost/pool/pool_alloc.hpp >, 31\n67Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Header < boost/pool/simple_se gregated_storage.hpp >, 41\nHeader < boost/pool/singleton_pool.hpp >, 45\nHow do I use Pool?, 3\nInstallation, 3\nMacro BOOST_POOL_V ALID ATE_INTERN ALS, 45\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nStruct f ast_pool_allocator_tag, 37\nStruct object_creator , 49\nStruct pool_allocator_tag, 32\nStruct template rebind, 35, 36, 40, 41\nHow Contiguous Chunks are Handled\nalignment, 15\nallocation, 15\nblock, 15\nchunk, 15\nmemory , 15\nobjects, 15\nordered, 15\npadding, 15\nsize, 15\nsizeof, 15\nHow do I use Pool?\nheaders, 3\ninclude, 3\ninterf ace, 3\nI\ninclude\nClass template object_pool, 24\nDocumentation Naming and F ormatting Con ventions, 2\nHow do I use Pool?, 3\nInstallation, 3\nInstallation\nbuild, 3\nheaders, 3\ninclude, 3\ninstallation, 3\ninstallation\nInstallation, 3\ninterf ace\nAppendix B: F AQ, 50\nAppendix H: Future plans, 52\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template singleton_pool, 46\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/singleton_pool.hpp >, 45\nHow do I use Pool?, 3\nIntroduction, 2\nObject_pool, 6\npool, 4\nPool Interf aces, 4\npool_allocator , 8\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nThe UserAllocator Concept, 21\nIntroduction\n68Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/allocation, 2\nchunk, 2\nconcepts, 2\ndeallocation, 2\ninterf ace, 2\nmemory , 2\nobjects, 2\nsegregated, 2\nIntroduction and Ov ervie w\novervie w, 2\nis_from\nClass template object_pool, 22, 24\nClass template pool, 27, 29, 31\nClass template singleton_pool, 46, 48\nObject_pool, 6\npool, 4\nSingleton_pool, 7\nJ\njamfile\nBuilding the Test Programs, 3\nM\nMacro BOOST_POOL_V ALID ATE_INTERN ALS\nBOOST_POOL_V ALID ATE_INTERN ALS, 45\nheaders, 45\nsegregated, 45\nmain\nClass template f ast_pool_allocator , 38\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nHeader < boost/pool/pool_alloc.hpp >, 31\nSingleton_pool, 7\nmalloc\nAllocation and Deallocation, 16\nAppendix G: References, 51\nBasic ideas behind pooling, 10\nClass template object_pool, 22, 23\nClass template pool, 27, 28, 30, 31\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 47\nObject_pool, 6\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25, 26\nUserAllocator Requirements, 21\nmalloc_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nmalloc_need_resize\nClass template pool, 27, 28\nmax_size\nClass template f ast_pool_allocator , 37, 39\nClass template pool_allocator , 33, 34\npool_allocator , 8\n69Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/memory\nAppendix B: F AQ, 50\nAppendix G: References, 51\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template f ast_pool_allocator , 38, 39\nClass template object_pool, 22, 23, 24, 25\nClass template pool, 26, 27, 28, 29, 30\nClass template pool_allocator , 33\nClass template simple_se gregated_storage, 41, 42, 44\nClass template singleton_pool, 46\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13, 14\nHeader < boost/pool/object_pool.hpp >, 22\nHeader < boost/pool/pool.hpp >, 25\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHow Contiguous Chunks are Handled, 15\nIntroduction, 2\nObject_pool, 6\npool, 4\npool_allocator , 8\nSegregation, 16\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_ne w_delete, 25\nThe UserAllocator Concept, 21\nUserAllocator Requirements, 21\nmute x\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nN\nnaming\nDocumentation Naming and F ormatting Con ventions, 2\nnew\nBasic ideas behind pooling, 10\nClass template object_pool, 23, 25\nClass template pool, 28, 30\nConstructors, Destructors, and State, 16\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\npool, 4\nStruct def ault_user_allocator_ne w_delete, 25\nnextof\nClass template object_pool, 22, 23\nClass template pool, 27, 29\nClass template simple_se gregated_storage, 42, 43\nO\nobjects\nAppendix B: F AQ, 50\nAppendix F: Other Implementations, 51\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template f ast_pool_allocator , 38\nClass template object_pool, 22, 23, 24\n70Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Class template pool, 27, 28, 29, 30\nClass template pool_allocator , 33\nClass template simple_se gregated_storage, 42, 45\nClass template singleton_pool, 46\nDocumentation Naming and F ormatting Con ventions, 2\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13, 14\nHeader < boost/pool/object_pool.hpp >, 22\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHeader < boost/pool/singleton_pool.hpp >, 45\nHow Contiguous Chunks are Handled, 15\nIntroduction, 2\nObject_pool, 6\npool, 4\npool_allocator , 8\nSegregation, 16\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nStruct object_creator , 48, 49\nThe UserAllocator Concept, 21\nUserAllocator Requirements, 21\nobject_creator\nClass template singleton_pool, 46\nStruct object_creator , 49\nObject_pool\nallocation, 6\nautomatic, 6\nchunk, 6\nconstruct, 6\ndestro y, 6\ndifference_type, 6\nelement_type, 6\nfree, 6\ninterf ace, 6\nis_from, 6\nmalloc, 6\nmemory , 6\nobjects, 6\nobject_pool, 6\nsize, 6\nsize_type, 6\ntemplate, 6\nuser_allocator , 6\nobject_pool\nClass template object_pool, 22, 23\nHeader < boost/pool/object_pool.hpp >, 22\nObject_pool, 6\nStruct def ault_user_allocator_malloc_free, 26\nordered\nAllocation and Deallocation, 16\nBasic ideas behind pooling, 10\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template pool, 27, 28, 29, 30, 31\nClass template simple_se gregated_storage, 42, 43, 44\nClass template singleton_pool, 46, 48\nConstructors, Destructors, and State, 16\n71Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/How Contiguous Chunks are Handled, 15\npool, 4\npool_allocator , 8\nSegregation, 16\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nordered_free\nClass template pool, 27, 30, 31\nClass template simple_se gregated_storage, 42, 44\nClass template singleton_pool, 46, 48\npool, 4\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nordered_free_n\nClass template simple_se gregated_storage, 42, 44\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nordered_malloc\nClass template pool, 27, 30\nClass template singleton_pool, 46, 48\npool, 4\nSingleton_pool, 7\nordered_malloc_need_resize\nClass template pool, 27, 28\nother\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nStruct template rebind, 35, 36, 40, 41\novervie w\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nIntroduction and Ov ervie w, 2\nP\npadding\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHow Contiguous Chunks are Handled, 15\npointer\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\npool\nalignment, 4\nblock, 4\nchunk, 4\nClass template object_pool, 22\nClass template pool, 27\ndefault_user_allocator_malloc_free, 4\ndefault_user_allocator_ne w_delete, 4\ndifference_type, 4\nfree, 4\ninterf ace, 4\nis_from, 4\nmalloc, 4\n72Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/memory , 4\nnew, 4\nobjects, 4\nordered, 4\nordered_free, 4\nordered_malloc, 4\npool, 4\npurge_memory , 4\nrelease_memory , 4\nsegregated, 4\nsize, 4\nsize_type, 4\ntemplate, 4\nuser_allocator , 4\nPool Interf aces\ninterf ace, 4\npool_allocator\naddress, 8\nallocate, 8\nallocation, 8\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\nconstruct, 8\nconst_pointer , 8\nconst_reference, 8\ndeallocate, 8\ndestro y, 8\ndifference_type, 8\nfast_pool_allocator , 8\nfast_pool_allocator_tag, 8\ninterf ace, 8\nmax_size, 8\nmemory , 8\nobjects, 8\nordered, 8\nother , 8\npointer , 8\npool_allocator , 8\npool_allocator_tag, 8\nrebind, 8\nreference, 8\nsingleton, 8\nsingleton_pool, 8\nsize, 8\nsize_type, 8\nStruct template rebind, 35, 36\ntemplate, 8\nuser_allocator , 8\nvalue_type, 8\npool_allocator_tag\npool_allocator , 8\nStruct pool_allocator_tag, 32\nportable\nAppendix F: Other Implementations, 51\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\npurge_memory\nClass template pool, 27, 29\nClass template singleton_pool, 46, 48\n73Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/pool, 4\nSingleton_pool, 7\nR\nrebind\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\nStruct template rebind, 35, 36, 40, 41\nreference\nClass template f ast_pool_allocator , 37\nClass template pool_allocator , 33\npool_allocator , 8\nrelease_memory\nClass template pool, 27, 29\nClass template singleton_pool, 46, 48\npool, 4\nSingleton_pool, 7\nS\nsegregate\nClass template simple_se gregated_storage, 42, 45\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nsegregated\nAppendix F: Other Implementations, 51\nAppendix G: References, 51\nBasic ideas behind pooling, 10\nClass template object_pool, 23\nClass template pool, 27, 28, 29\nClass template simple_se gregated_storage, 41, 42, 43, 44, 45\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/pool.hpp >, 25\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nIntroduction, 2\nMacro BOOST_POOL_V ALID ATE_INTERN ALS, 45\npool, 4\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSymbol Table, 16\nSegregation\nblock, 16\nchunk, 16\nmemory , 16\nobjects, 16\nordered, 16\nsize, 16\nset_max_size\nClass template pool, 27, 30\nset_ne xt_size\nClass template object_pool, 22, 25\nClass template pool, 27, 29\nSimple Se gregated Storage\nallocation, 12\nblock, 12\nchunk, 12\n74Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/deallocation, 12\nmemory , 12\nobjects, 12\nsegregated, 12\nsize, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!)\nadd_block, 16\nadd_ordered_block, 16\nalignment, 16\nblock, 16\nchunk, 16\nfree, 16\nfree_n, 16\ninterf ace, 16\nmalloc, 16\nmalloc_n, 16\nmemory , 16\nobjects, 16\nordered, 16\nordered_free, 16\nordered_free_n, 16\nsegregate, 16\nsegregated, 16\nsimple_se gregated_storage, 16\nsize, 16\nsize_type, 16\ntemplate, 16\nsimple_se gregated_storage\nClass template pool, 27\nClass template simple_se gregated_storage, 42\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nsingleton\nAppendix H: Future plans, 52\nBoost Pool Interf aces - What interf aces are pro vided and when to use each one., 3\nClass template f ast_pool_allocator , 38\nClass template pool_allocator , 33, 34\nClass template singleton_pool, 45, 46, 47, 48\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/singleton_pool.hpp >, 45\npool_allocator , 8\nSingleton_pool, 7\nStruct f ast_pool_allocator_tag, 36\nStruct object_creator , 48, 49\nStruct pool_allocator_tag, 32\nSingleton_pool\nchunk, 7\ndifference_type, 7\nfree, 7\ninterf ace, 7\nis_from, 7\nmain, 7\nmalloc, 7\nmemory , 7\nobjects, 7\nordered, 7\nordered_free, 7\nordered_malloc, 7\npurge_memory , 7\n75Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/release_memory , 7\nsingleton, 7\nsingleton_pool, 7\nsize, 7\nsize_type, 7\ntag, 7\ntemplate, 7\nuser_allocator , 7\nsingleton_pool\nAppendix H: Future plans, 52\nClass template f ast_pool_allocator , 38\nClass template pool_allocator , 33, 34\nClass template singleton_pool, 45, 46, 47, 48\nHeader < boost/pool/singleton_pool.hpp >, 45\npool_allocator , 8\nSingleton_pool, 7\nStruct f ast_pool_allocator_tag, 36\nStruct object_creator , 48, 49\nStruct pool_allocator_tag, 32\nsize\nAllocation and Deallocation, 16\nBasic ideas behind pooling, 10\nClass template f ast_pool_allocator , 37, 38, 39\nClass template object_pool, 22, 23, 24, 25\nClass template pool, 27, 28, 29, 30, 31\nClass template pool_allocator , 33, 34, 35\nClass template simple_se gregated_storage, 41, 42, 43, 44, 45\nClass template singleton_pool, 46, 48\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13, 14\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHeader < boost/pool/singleton_pool.hpp >, 45\nHow Contiguous Chunks are Handled, 15\nObject_pool, 6\npool, 4\npool_allocator , 8\nSegregation, 16\nSimple Se gregated Storage, 12\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nSymbol Table, 16\nTemplate P arameters, 16\nThe UserAllocator Concept, 21\nTypedefs, 16\nUserAllocator Requirements, 21\nsizeof\nGuaranteeing Alignment - Ho w we guarantee alignment portably ., 13\nHeader < boost/pool/pool_alloc.hpp >, 31\nHow Contiguous Chunks are Handled, 15\nsize_type\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template simple_se gregated_storage, 42\nClass template singleton_pool, 46\n76Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/Object_pool, 6\npool, 4\npool_allocator , 8\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nStruct def ault_user_allocator_malloc_free\nblock, 26\ndefault_user_allocator_malloc_free, 26\ndifference_type, 26\nfree, 26\nheaders, 26\nmalloc, 26\nobjects, 26\nobject_pool, 26\nsize, 26\nsize_type, 26\ntemplate, 26\nStruct def ault_user_allocator_ne w_delete\nblock, 26\ndefault_user_allocator_ne w_delete, 25\ndifference_type, 25\nfree, 25, 26\nheaders, 25\nmalloc, 25, 26\nmemory , 25\nnew, 25\nobjects, 25\nsize, 25\nsize_type, 25\ntemplate, 25\nStruct f ast_pool_allocator_tag\nfast_pool_allocator_tag, 37\nheaders, 37\nsingleton, 36\nsingleton_pool, 36\ntemplate, 36\nStruct object_creator\nheaders, 49\nobjects, 48, 49\nobject_creator , 49\nsingleton, 48, 49\nsingleton_pool, 48, 49\nStruct pool_allocator_tag\nheaders, 32\npool_allocator_tag, 32\nsingleton, 32\nsingleton_pool, 32\nStruct template rebind\nfast_pool_allocator , 40, 41\nheaders, 35, 36, 40, 41\nother , 35, 36, 40, 41\npool_allocator , 35, 36\nrebind, 35, 36, 40, 41\ntemplate, 35, 36, 39, 40, 41\nSymbol Table\nblock, 16\n77Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/chunk, 16\nsegregated, 16\nsize, 16\nT\ntag\nClass template singleton_pool, 46, 47\nSingleton_pool, 7\ntemplate\nClass template f ast_pool_allocator , 37, 38, 40\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template object_pool, 22, 24\nClass template pool, 26, 27\nClass template pool_allocator , 32, 33, 34, 35\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 35, 36\nClass template simple_se gregated_storage, 41, 42\nClass template singleton_pool, 45, 46, 47\nDocumentation Naming and F ormatting Con ventions, 2\nHeader < boost/pool/object_pool.hpp >, 22\nHeader < boost/pool/pool.hpp >, 25\nHeader < boost/pool/pool_alloc.hpp >, 31\nHeader < boost/pool/simple_se gregated_storage.hpp >, 41\nHeader < boost/pool/singleton_pool.hpp >, 45\nObject_pool, 6\npool, 4\npool_allocator , 8\nSimple Se gregated Storage (Not for the f aint of heart - Embedded programmers only!), 16\nSingleton_pool, 7\nStruct def ault_user_allocator_malloc_free, 26\nStruct def ault_user_allocator_ne w_delete, 25\nStruct f ast_pool_allocator_tag, 36\nStruct template rebind, 35, 36, 39, 40, 41\nTemplate P arameters, 16\nThe UserAllocator Concept, 21\nTemplate P arameters\nsize, 16\ntemplate, 16\ntry_malloc_n\nClass template simple_se gregated_storage, 42, 43\nTypedefs\nsize, 16\nU\nUserAllocator Concept\nblock, 21\nchunk, 21\nconcepts, 21\ninterf ace, 21\nmemory , 21\nobjects, 21\nsize, 21\ntemplate, 21\nUserAllocator Requirements\nblock, 21\nmalloc, 21\nmemory , 21\nobjects, 21\n78Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/size, 21\nuser_allocator\nClass template f ast_pool_allocator , 37\nClass template object_pool, 22\nClass template pool, 27\nClass template pool_allocator , 33\nClass template singleton_pool, 46\nObject_pool, 6\npool, 4\npool_allocator , 8\nSingleton_pool, 7\nV\nvalue_type\nClass template f ast_pool_allocator , 37\nClass template f ast_pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 40\nClass template pool_allocator , 33\nClass template pool_allocator<v oid, UserAllocator , Mute x, Ne xtSize, MaxSize>, 36\npool_allocator , 8\n79Boost.Pool\nXML to PDF by RenderX XEP XSL-FO F ormatter , visit us at http://www .renderx.com/" } ]
{ "category": "App Definition and Development", "file_name": "pool.pdf", "project_name": "ArangoDB", "subcategory": "Database" }
[ { "data": "The Next Evolution in \nCI/CD Technology\nA WHITEPAPER PUBLISHED BY THE\nCD FOUNDATION’S CDEVENTS PROJECT TEAM\nUpdated May 2023CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.dev\nThis whitepaper describes the newest technology in CI/CD – CDEvents. It is intended for DevOps \nEngineers, Project Managers/Directors, CTOs, and Cloud Architects who are interested in evolving \ntheir DevOps pipelines to become more scalable, robust, measurable, and visible, using a \ntechnology-agnostic solution to provide interoperability.\nThe technology described is still in its very early stages, and the concepts in it could change quite \nsubstantially as we go along, so please join us to make sure this technology evolves into something \nwe could all benefit from.\nWhat is CDEvents \nToday’s CI/CD systems often comprise of services that do not talk to each other in a standardized \nway. Such services include pipeline orchestrators, build/test tools, deployment tools, metrics \ncollectors and visualizers. This leads to problems related to interoperability, notification of failure \nissues, and poor automation.\nThe Continuous Delivery Foundation’s CDEvents project has been created to solve the \ninteroperability problem. The mission of the CDEvents project is to define standards for an \nevent-based CI/CD pipeline to support CI/CD systems with a decoupled architecture.\nThe CDEvents project focuses on both event-based CI/CD standards and best practices for \nevent-driven CI/CD systems. The CDEvents project aims to define the common language of the \nCI/CD ecosystem events, so it provides a vocabulary, a specification as well as SDKs. CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devCDEvents Benefits\nCDEvents delivers:\n• Easy to scale pipelines\n• Increased automation between workflows\n• A simple way to enhance or modify workflows\n• Standardized notifications for metrics collectors and visualizers\nA decoupled CI/CD architecture is easy to scale and makes the CI/CD pipelines more resilient to \nfailures, which is critical as the end-to-end software production and delivery pipelines grow more \nand more complex, not least in a microservices architecture with thousands of independent \npipelines. Using CDEvents also increases automation when connecting workflows from different \nsystems to each other, and as a result, empowers tracing/visualizing/auditing of the connected \nworkflows through these events. Additionally, CDEvents make it super easy to switch between \ndifferent CI/CD tooling to enhance or modify your workflows quickly.\nThe Goal of the CDEvents Project \nThe CDEvents project’s mission is to standardize an event protocol specification that caters to \ntechnology-agnostic machine-to-machine communication in CI/CD systems. This specification will \nbe published, reviewed, and agreed upon between relevant Linux Foundation projects/members. \nThe CDEvents project aims to provide reference implementations such as event consumers/\nlisteners and event producers/senders on top of for example CloudEvents.\nHistory\nBefore we dive in further, a bit of history. The Continuous Delivery Foundation’s Interoperability \nSpecial Interest Group(SIG) was created in early 2020 to discuss and research interoperability in the \nCD space. One of the workstreams of the SIG was focused on interoperability through ‘events.’ In \nearly 2021 the workstream was transformed into a SIG of its own, and towards the end of that year, \nthe CDEvents project was created. The project was proposed as a CDF incubating project and was \naccepted by the CDF Technology Oversight Committee in December 2021.CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devCDEvents Specification\nTo define CDEvents the contributors understood the need to define a common standard and \nvocabulary. Following is a description of the specification. \nCDEvents Topics\nEvents provide interoperability between CI/CD tooling through topics. Part of the mission of \nthe CDEvents project is to determine the best usage and process for CDEvents and to define a \ncommon standard. The CDEvents project team is working to define:\n• When are events suited for triggers, audits, monitoring, and management?\n• Common guidelines for at-least-once, at-most-once, exactly once, and ordering logic.\n• When to apply particular strategies\n• Events to be used by tools for orchestration/workflows\n• Pipeline to pipeline communication via events\n• Tracing/auditing/graphing/visualizing of the entire process, e.g., through events showing what \nhas occurred.\n• CDEvents Metrics, e.g., how many versions have been deployed, how many PRs (Pull Requests) \nhave been raised, and how many events have been issued?\n• How are events related and how are they ordered (links vs trace context)?\nCDEvents Vocabulary\nMost CI/CD platforms define their abstractions, data model, and nomenclature. The interoperability \nSIG has already been collecting this level of data from various platforms. Many labels are shared \nacross platforms, but sometimes the same label bears different meanings in different projects. To \nachieve interoperability through events, a nomenclature with shared semantics across platforms \nwas seen to be essential. This nomenclature has its roots in the “Rosetta Stone” for CI/CD, first \ninitiated through the Interoperability SIG in CDF. The CDEvents vocabulary will continuously revise \nits vocabulary based on the evolution of that document and related publications until the first \nofficial release of the CDEvents protocol specification is published.CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devTo achieve shared semantics, the CDEvents project first created a vocabulary describing six \n‘buckets’ to group the different but common CDEvents together.\n• Core Events: this includes core events related to core activities and orchestration that need to \nexist to be able to deterministically and continuously be able to deliver software to users.\n• Source Code Version Control Events : Events emitted by changes in source code or by the cre -\nation, modification, or deletion of new repositories that hold source code.\n• Continuous Integration Events : includes events related to building, testing, packaging, and \nreleasing software artifacts, usually binaries.\n• Continuous Deployment Events : include events related to environments where the \nartifacts produced by the integration pipelines actually run. These are services running in \na specific environment (dev, QA, production), or embedded software running in a specific \nhardware platform.\n• Continuous Operations Events : include events related to the operation of services deployed in \ntarget environments, tracking of incidents, and their resolution. Incidents, and their resolution, \ncan be detected by a number of different actors, like the end-user, a quality gate, a monitoring \nsystem, an SRE through a ticketing system, or even the service itself.\n• CloudEvents Binding for CDEvents : The CloudEvents Binding for CDEvents defines how \nCDEvents are mapped to CloudEvents headers and body.\nWithin each ‘phase,’ a few abstractions have been defined. For instance, the ‘Core Events’ phase \ndefines “Task Runs” and “Pipeline Runs”. The ‘Continuous Integration Pipeline Events’ phase defines \n“Build,” “Test Case,” “Test Suite,” and “Artifact.”\nThese phases can also be considered as different profiles of the vocabulary that can be adopted \nindependently. Also notice that the term ‘pipeline’ is used to denote a pipeline, workflow, and \nrelated concepts. We also use the term ‘task’ to denote a job/stage/step.\nWith the vocabulary defined, CDEvents can be easily assigned to each phase. Within each phase, \nabstractions can be assigned. For instance, the Core phase defines “ Task Runs” and “ Pipeline Runs”. \nA Pipeline Run can be:\n• Queued\n• Started\n• Finished \nWhile these six ‘phases’ define the most common CI/CD activities, they are not exhaustive. In the \nfuture, other activities may be included, for instance, monitoring. CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devCDEvents Format\nCDEvents can be encapsulated in different message/stream/event envelopes, and the first such \nbinding prepared by the CDEvents project uses CloudEvents with CDEvents-specific extensions and \npayload structure, which is based on the CDEvent’s vocabulary.\nCDEvents producers may use the payload to provide extra context to the event’s consumer. The \npayload however is not meant to transport large amounts of data. Data such as logs or software \nartifacts should be linked from the event and not embedded into the events. CDEvents follows the \nCloudEvents recommendation on event size and size limits.\nAll CDEvents contain information such as the type of event, the source of the event, the time \nthe event occurred and a unique identifier. Depending on its type it also contains multiple other \nattributes, of which some are mandatory and some are optional.\nFor more information about the CDEvents format, please visit the CDEvents Documentation site.\nCDEvents Use Cases\nUse cases are key to understanding CDEvents. When defining CDEvents and their attributes, we \nmust know what minimal set of information is needed to satisfy a particular use case. There are two \nroot use cases:\n• The first use case is interoperability, making it possible for one CI/CD tool to consume events \nproduced by another without the need for ‘static’ imperative definitions. This use case focuses \non how to make CI/CD tools work together in a more automated, streamlined manner.\n• The second one is observability and metrics. Essential to improving the CI/CD pipeline is the \nability of the pipeline to collect events from different CI/CD tools. This collection is essential for \nthe pipeline to correlate CDEvents and process them consistently, building an end-to-end view \nof the overall CI/CD workflow. CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devUse Case One: Interoperability\nIn most enterprise organizations, it is impossible to have one CI/CD setup to rule all development \nprojects. Different languages, platforms, and tooling might be required for each. For this reason, \nmost organizations want to let teams choose their own optimal CI/CD setup. Let’s consider the \nfollowing use case. In our fictional organization, many of the software development teams prefer \nto use Zuul for its dependency handling and scalability. But other teams prefer GoCD. Some teams \nstarted using GitLab and prefer a central platform for source code and the project tools. Other \nteams prefer Jenkins and rely on a wide variety of plugins. To further complicate things, our fictional \ncompany doesn’t build all the software in-house. They instead use suppliers.\nAs our fictional company needs to understand and receive software modules built using different \ntooling. The problem is that Zuul artifacts are a bit different from GoCD artifacts, which is a bit \ndifferent from GitLab artifacts, or artifacts produced by a custom Jenkins build. The solution is to \nwrite custom translation or “glue code” to be able to understand and receive all these diverse built \nsoftware modules.\nAnd this diversity does not apply only to building artifacts. It can apply to many steps in the pipeline, \nincluding: \n• Source changes\n• Build activities\n• Test runs\n• Failures\n• Compositions (multiple artifacts)\n• Announcements\nIn a CDEvents-based system, it is unnecessary to develop custom ‘glue code’ for each activity. \nTo allow our fictional company to announce new artifacts in a standardized format, CDEvents \nhas predefined the format taking care of the interoperability between the diverse build systems. \nUse Case Two: Visualization and Metrics\nConsider the following CI/CD setup. Code is written and maintained on GitHub. When changes \nare made, they go through different tests, maintained by different teams, which use different \ntechnologies. Some tests are running in GitHub directly as GitHub Actions. Some others are \nexecuted in Jenkins and others as Tekton pipelines. Releases are managed through Tekton as well, \nwhile deployments are managed with Argo. Keptn is used to manage remediation strategies on \nproduction clusters.CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devIf all these systems supported events in some predefined format, they could be easily collected. \nWhen they are not unified, teams must build event collectors that support multiple ways of \ncollecting payloads. For example, both Tekton and Keptn use CloudEvents, but there is no shared \nsemantics for interacting between them.\nThe goal is to have all platforms share the same format for events allowing a standard event \ncollector across all tools and platforms managing CI/CD pipelines. For example, to visualize the flow \nof a change from when it’s written, through the test, release, deploy, and possibly rollback, there \nneeds to be enough information in the events to be able to correlate the data across all tools. \nCDEvents addresses unifying the data through a standard event collector. \nTracking metrics across the CI/CD Pipelines is critical to improving development processes by \nanswering the question ‘How effective is the DevOps setup.’ To answer that question metrics need \nto be commonly defined, collected, and visualized. CDEvents collect data from heterogeneous \nsources, making it possible to store and process it consistently.\nCDEvents Proof of Concept\nThe CDEvents contributors completed a Proof of Concept using Tekton and Keptn. The PoC shows \na combined effort between Keptn and Tekton. In the PoC Tekton played the role of the pipeline \nexecutor doing the heavy lifting with building and deploying whereas Keptn handled the business \ndecision. More information about the PoC can be found on the PoC GitHub page.\nYour Next Steps (Call to action)\nGet involved in the CDEvents project at the Continuous Delivery Foundation. CDEvents will be \ncritical as we move away from traditional monolithic development models to cloud-native models \nwhere decoupled applications require thousands of CI/CD workflows. Building a standard CDEvents \nprotocol specification that can be easily supported by all CI/CD tooling is required. Contributing to \nthe CDEvents team is a way for you to get involved in solving this critical piece of the CI/CD puzzle. \nGet involved by going to https://cdevents.dev/community/. You will find community information \nwhich is the easiest way to get started.CDEVENTS - THE NEXT EVOLUTION IN CI/CD TECHNOLOGY - https://cdevents.devConclusion\nCDEvents is the next evolution of CI/CD pipeline orchestration and visualization. Every DevOps \nEngineer has understood the challenges of building ‘plugins,’ ‘glue code,’ and one-off scripts to build \na single CI/CD pipeline. CDEvents will revolutionize the way pipelines are coordinated and unified \nproviding the end-to-end CI/CD pipeline visibility and data collection needed for both processing \nand tracking key workflow metrics. And most critically, as we move into a cloud-native architecture \nwith microservices, scaling the end-to-end CI/CD pipeline to thousands of workflows is already \nhappening. CDEvents will allow your pipeline to scale, and make it easy to stand up a new workflow \nas often as needed. \nLearn more at cdevents.dev\nAbout the Continuous \nDelivery Foundation\nThe Continuous Delivery Foundation (CDF) serves as the \nvendor-neutral home of many of the fastest-growing projects \nfor continuous integration/ continuous delivery (CI/CD). It \nfosters vendor-neutral collaboration between the industry’s \ntop developers, end-users, and vendors to further CI/CD best \npractices and industry specifications. Its mission is to grow \nand sustain projects that are part of the broad and growing \ncontinuous delivery ecosystem" } ]
{ "category": "App Definition and Development", "file_name": "CDEvents_Whitepaper.pdf", "project_name": "CDEvents", "subcategory": "Streaming & Messaging" }
[ { "data": "Contents \nConcepts \nScheduler \nFifoWorker \nExceptionTranslator \nStateBase \nSimpleState \nState \nEvent \nstate_machine.hpp \nClass template state_machine \nasynchronous_state_machine.hpp \nClass template asynchronous_state_machine \nevent_processor.hpp \nClass template event_processor \nfifo_scheduler.hpp \nClass template fifo_scheduler \nexception_translator.hpp \nClass template exception_translator \nnull_exception_translator.hpp \nClass null_exception_translator \n \nsimple_state.hpp \nEnum history_mode \nClass template simple_state \nstate.hpp \nClass template state \nshallow_history.hpp \nClass template shallow_history \ndeep_history.hpp \nClass template deep_history \n \nevent_base.hpp \nClass event_base \nevent.hpp \nClass template event \n \ntransition.hpp \nClass template transition \nin_state_reaction.hpp \nClass template in_state_reaction \ntermination.hpp \nClass template termination \ndeferral.hpp \nClass template deferral \ncustom_reaction.hpp \nClass template custom_reaction \nresult.hpp \nClass result \nThe Boost Statechart Library \nReference Page 1 of 35 The Boost Statechart Library - Reference \n2008/01/06Concepts \nScheduler concept \nA Scheduler type defines the following: \n/circle6What is passed to the constructors of event_processor<> subtypes and how the lifetime of such objects \nis managed \n/circle6Whether or not multiple event_processor<> subtype objects can share the same queue and sched uler \nthread \n/circle6How events are added to the schedulers' queue \n/circle6Whether and how to wait for new events when the sch edulers' queue runs empty \n/circle6Whether and what type of locking is used to ensure thread-safety \n/circle6Whether it is possible to queue events for no longe r existing event_processor<> subtype objects and \nwhat happens when such an event is processed \n/circle6What happens when one of the serviced event_processor<> subtype objects propagates an exception \nFor a Scheduler type S and an object cpc of type const S::processor_context the following \nexpressions must be well-formed and have the indica ted results: \nTo protect against abuse, all members of S::processor_context should be declared private. As a result, \nevent_processor<> must be a friend of S::processor_context . \nFifoWorker concept \nA FifoWorker type defines the following: \n/circle6Whether and how to wait for new work items when the internal work queue runs empty \n/circle6Whether and what type of locking is used to ensure thread-safety \nFor a FifoWorker type F, an object f of that type, a const object cf of that type, a parameterless function object \nw of arbitrary type and an unsigned long value n the following expressions/statements must be well- formed \nand have the indicated results: Expression Type Result \ncpc.my_scheduler() S & A reference to the scheduler \ncpc.my_handle() S::processor_handle The handle identifying the event_processor<> subtype object \nExpression/Statement Type Effects/Result \nF::work_item boost::function0< \nvoid > \nF() or F( false ) FConstructs a non-blocking (see below) object of the \nFifoWorker type. In single-threaded builds the seco nd \nexpression is not well-formed \nF( true ) FConstructs a blocking (see below) object of the FifoWorker \ntype. Not well-formed in single-threaded builds \nf.queue_work_item \n( w ); Constructs and queues an object of type F::work_item , \npassing w as the only argument \nf.terminate(); Creates and queues an object of type F::work_item that, \nwhen later executed in operator()() , leads to a modification \nof internal state so that terminated() henceforth returns \ntrue \ntrue if terminate() has been called and the resulting work \nitem has been executed in operator()() . Returns false Page 2 of 35 The Boost Statechart Library - Reference \n2008/01/06ExceptionTranslator concept \nAn ExceptionTranslator type defines how C++ excepti ons occurring during state machine operation are tr anslated \nto exception events. \nFor an ExceptionTranslator object et , a parameterless function object a of arbitrary type returning result and a \nfunction object eh of arbitrary type taking a const event_base & parameter and returning result the \nfollowing expression must be well-formed and have t he indicated results: \nStateBase concept \nA StateBase type is the common base of all states o f a given state machine type. \nstate_machine<>::state_base_type is a model of the StateBase concept. \nFor a StateBase type S and a const object cs of that type the following expressions must be wel l-formed and \nhave the indicated results: cf.terminated(); bool otherwise \n \nMust only be called from the thread that also calls \noperator()() \nf( n ); unsigned long Enters a loop that, with each cycle, dequeues and c alls \noperator()() on the oldest work item in the queue. \nThe loop is left and the number of executed work it ems \nreturned if one or more of the following conditions are met: \n/circle6f.terminated() == true \n/circle6The application is single-threaded and the internal \nqueue is empty \n/circle6The application is multi- threaded and the internal queue \nis empty and the worker was created as non-blocking \n/circle6n != 0 and the number of work items that have been \nprocessed since operator()() was called equals n \nIf the queue is empty and none of the above conditi ons are \nmet then the thread calling operator()() is put into a wait \nstate until f.queue_work_item() is called from another \nthread. \n \nMust only be called from exactly one thread \nf(); unsigned long Has exactly the same semantics as f( n ); with n == 0 (see \nabove) \nExpression Type Effects/Result \net \n( a, eh ); result 1. Attempts to execute return a(); \n2. If a() propagates an exception, the exception is caught \n3. Inside the catch block calls eh , passing a suitable stack-allocated model of the \nEvent concept \n4. Returns the result returned by eh \nExpression Type Result \ncs.outer_state_ptr() const S * 0 if cs is an outermost state , a pointer to the direct outer state of \ncs otherwise \nA value unambiguously identifying the most-derived type of Page 3 of 35 The Boost Statechart Library - Reference \n2008/01/06SimpleState concept \nA SimpleState type defines one state of a particula r state machine. \nFor a SimpleState type S and a pointer pS pointing to an object of type S allocated with new the following \nexpressions/statements must be well-formed and have the indicated effects/results: \nState concept \nA State is a refinement of SimpleState (that is, except for the default constructor a Sta te type must also satisfy \nSimpleState requirements). For a State type S, a pointer pS of type S * pointing to an object of type S allocated \nwith new , and an object mc of type state< S, C, I, h >::my_context the following \nexpressions/statements must be well-formed: cs.dynamic_type() S::id_type cs . S::id_type values are comparable with operator==() \nand operator!=() . An unspecified collating order can be \nestablished with std::less< S::id_type > . In contrast to \ntypeid( cs ) , this function is available even on platforms that \ndo not support C++ RTTI (or have been configured to not \nsupport it) \ncs.custom_dynamic_type_ptr< \n Type >() const Type \n*A pointer to the custom type identifier or 0. If != 0 , Type must \nmatch the type of the previously set pointer. This function is \nonly available if \nBOOST_STATECHART_USE_NATIVE_RTTI is not defined \nExpression/Statement Type Effects/Result/Notes \nsimple_state < \n S, C, I, h > * pB = \n pS; simple_state< S, C, I, h > must be an \nunambiguous public base of S. See \nsimple_state<> documentation for the \nrequirements and semantics of C, I and h\nnew S() S * Enters the state S. Certain functions must not be \ncalled from S::S() , see simple_state<> \ndocumentation for more information \npS->exit(); Exits the state S (first stage). The definition of \nan exit member function within models of the \nSimpleState concept is optional since \nsimple_state<> already defines the following \npublic member: void exit() {} . exit() is \nnot called when a state is exited while an \nexception is pending, see \nsimple_state<>::terminate() for more \ninformation \ndelete pS; Exits the state S (second stage) \nS::reactions An mpl::list<> that is either \nempty or contains instantiations of \nthe custom_reaction , \nin_state_reaction , deferral , \ntermination or transition class \ntemplates. If there is only a single \nreaction then it can also be \ntypedef ed directly, without \nwrapping it into an mpl::list<> The declaration of a reactions member \ntypedef within models of the SimpleState \nconcept is optional since simple_state<> \nalready defines the following public member: \ntypedef mpl::list<> reactions; \nExpression/Statement Type Effects/Result/Notes Page 4 of 35 The Boost Statechart Library - Reference \n2008/01/06Event concept \nA Event type defines an event for which state machi nes can define reactions. \nFor a Event type E and a pointer pCE of type const E * pointing to an object of type E allocated with new the \nfollowing expressions/statements must be well-forme d and have the indicated effects/results: \nHeader <boost/statechart/state_machine.hpp> \nClass template state_machine \nThis is the base class template of all synchronous state machines. \nClass template state_machine parameters \nClass template state_machine synopsis state < S, C, I, h > * \n pB = pS; state< S, C, I, h > must be an unambiguous public base of S. See \nstate<> documentation for the requirements and semantics o f C, I and h\nnew S( mc ) S * Enters the state S. No restrictions exist regarding the functions tha t can be \ncalled from S::S() (in contrast to the constructors of models of the \nSimpleState concept). mc must be forwarded to state< S, C, I, h \n>::state() \nExpression/Statement Type Effects/Result/Notes \nconst event < E > * pCB = pCE; event< E > must be an unambiguous public base of E\nnew E( *pCE ) E * Makes a copy of pE \nTemplate parameter Requirements Semantics Default \nMostDerived The most-derived \nsubtype of this class \ntemplate \nInitialState A model of the \nSimpleState or State \nconcepts. The \nContext argument \npassed to the \nsimple_state<> or \nstate<> base of \nInitialState must \nbe MostDerived . \nThat is, \nInitialState must \nbe an outermost state \nof this state machine The state that is entered when \nstate_machine<> \n::initiate() is called \nAllocator A model of the \nstandard Allocator \nconcept Allocator::rebind<>::other \nis used to allocate and deallocate \nall simple_state subtype \nobjects and internal objects of \ndynamic storage duration std::allocator< void > \nExceptionTranslator A model of the \nExceptionTranslator \nconcept see ExceptionTranslator concept null_exception_translator Page 5 of 35 The Boost Statechart Library - Reference \n2008/01/06namespace boost \n{ \nnamespace statechart \n{ \n template< \n class MostDerived, \n class InitialState, \n class Allocator = std::allocator< void >, \n class ExceptionTranslator = null_exception_tran slator > \n class state_machine : noncopyable \n { \n public: \n typedef MostDerived outermost_context_type; \n \n void initiate (); \n void terminate (); \n bool terminated () const; \n \n void process_event ( const event_base & ); \n \n template< class Target > \n Target state_cast () const; \n template< class Target > \n Target state_downcast () const; \n \n // a model of the StateBase concept \n typedef implementation-defined state_base_type; \n // a model of the standard Forward Iterator c oncept \n typedef implementation-defined state_iterator; \n \n state_iterator state_begin () const; \n state_iterator state_end () const; \n \n void unconsumed_event ( const event_base & ) {} \n \n protected: \n state_machine (); \n ~state_machine (); \n \n void post_event ( \n const intrusive_ptr< const event_base > & ); \n void post_event ( const event_base & ); \n }; \n} \n} \nClass template state_machine constructor and destructor \nstate_machine(); \nEffects : Constructs a non-running state machine \n~state_machine(); \nEffects : Destructs the currently active outermost state an d all its direct and indirect inner states. Innermo st states \nare destructed first. Other states are destructed a s soon as all their direct and indirect inner state s have been \ndestructed. The inner states of each state are dest ructed according to the number of their orthogonal region. The \nstate in the orthogonal region with the highest num ber is always destructed first, then the state in t he region with \nthe second-highest number and so on \nNote : Does not attempt to call any exit member functions Page 6 of 35 The Boost Statechart Library - Reference \n2008/01/06Class template state_machine modifier functions \nvoid initiate(); \nEffects : \n1. Calls terminate() \n2. Constructs a function object action with a parameter-less operator()() returning result that \na. enters (constructs) the state specified with the InitialState template parameter \nb. enters the tree formed by the direct and indirect inner initial states of InitialState depth first. \nThe inner states of each state are entered accordin g to the number of their orthogonal region. The sta te \nin orthogonal region 0 is always entered first, the n the state in region 1 and so on \n3. Constructs a function object exceptionEventHandler with an operator()() returning result \nand accepting an exception event parameter that pro cesses the passed exception event, with the followi ng \ndifferences to the processing of normal events: \n/circle6From the moment when the exception has been thrown until right after the execution of the exception \nevent reaction, states that need to be exited are o nly destructed but no exit member functions are \ncalled \n/circle6Reaction search always starts with the outermost unstable state \n/circle6As for normal events, reaction search moves outward when the current state cannot handle the event. \nHowever, if there is no outer state (an outermost state has been reached) the reaction search is \nconsidered unsuccessful. That is, exception events will never be dispatched to orthogonal regions \nother than the one that caused the exception event \n/circle6Should an exception be thrown during exception even t reaction search or reaction execution then the \nexception is propagated out of the exceptionEventHandler function object (that is, \nExceptionTranslator is not used to translate exceptions thrown while processi ng an exception \nevent) \n/circle6If no reaction could be found for the exception eve nt or if the state machine is not stable after \nprocessing the exception event, the original except ion is rethrown. Otherwise, a result object is \nreturned equal to the one returned by simple_state<>::discard_event() \n4. Passes action and exceptionEventHandler to ExceptionTranslator::operator()() . If \nExceptionTranslator::operator()() throws an exception, the exception is propagated t o the \ncaller. If the caller catches the exception, the cu rrently active outermost state and all its direct a nd indirect \ninner states are destructed. Innermost states are d estructed first. Other states are destructed as soo n as all \ntheir direct and indirect inner states have been de structed. The inner states of each state are destru cted \naccording to the number of their orthogonal region. The state in the orthogonal region with the highes t \nnumber is always destructed first, then the state i n the region with the second-highest number and so on. \nContinues with step 5 otherwise (the return value i s discarded) \n5. Processes all posted events (see process_event() ). Returns to the caller if there are no more poste d \nevents \nThrows : Any exceptions propagated from ExceptionTranslator::operator()() . Exceptions never \noriginate in the library itself but only in code su pplied through template parameters: \n/circle6Allocator::rebind<>::other::allocate() \n/circle6state constructors \n/circle6react member functions \n/circle6exit member functions \n/circle6transition-actions \nvoid terminate(); \nEffects : \n1. Constructs a function object action with a parameter-less operator()() returning result that \nterminates the currently active outermost state, discards all remaining events and clears all history \ninformation \n2. Constructs a function object exceptionEventHandler with an operator()() returning result \nand accepting an exception event parameter that pro cesses the passed exception event, with the followi ng \ndifferences to the processing of normal events: Page 7 of 35 The Boost Statechart Library - Reference \n2008/01/06/circle6From the moment when the exception has been thrown until right after the execution of the exception \nevent reaction, states that need to be exited are o nly destructed but no exit member functions are \ncalled \n/circle6Reaction search always starts with the outermost unstable state \n/circle6As for normal events, reaction search moves outward when the current state cannot handle the event. \nHowever, if there is no outer state (an outermost state has been reached) the reaction search is \nconsidered unsuccessful. That is, exception events will never be dispatched to orthogonal regions \nother than the one that caused the exception event \n/circle6Should an exception be thrown during exception even t reaction search or reaction execution then the \nexception is propagated out of the exceptionEventHandler function object (that is, \nExceptionTranslator is not used to translate exceptions thrown while processi ng an exception \nevent) \n/circle6If no reaction could be found for the exception eve nt or if the state machine is not stable after \nprocessing the exception event, the original except ion is rethrown. Otherwise, a result object is \nreturned equal to the one returned by simple_state<>::discard_event() \n3. Passes action and exceptionEventHandler to ExceptionTranslator::operator()() . If \nExceptionTranslator::operator()() throws an exception, the exception is propagated t o the \ncaller. If the caller catches the exception, the cu rrently active outermost state and all its direct a nd indirect \ninner states are destructed. Innermost states are d estructed first. Other states are destructed as soo n as all \ntheir direct and indirect inner states have been de structed. The inner states of each state are destru cted \naccording to the number of their orthogonal region. The state in the orthogonal region with the highes t \nnumber is always destructed first, then the state i n the region with the second-highest number and so on. \nOtherwise, returns to the caller \nThrows : Any exceptions propagated from ExceptionTranslator::operator() . Exceptions never \noriginate in the library itself but only in code su pplied through template parameters: \n/circle6Allocator::rebind<>::other::allocate() \n/circle6state constructors \n/circle6react member functions \n/circle6exit member functions \n/circle6transition-actions \nvoid process_event( const event_base & ); \nEffects : \n1. Selects the passed event as the current event (he nceforth referred to as currentEvent ) \n2. Starts a new reaction search \n3. Selects an arbitrary but in this reaction search not yet visited state from all the currently active innermost \nstates . If no such state exists then continues with step 10 \n4. Constructs a function object action with a parameter-less operator()() returning result that does \nthe following: \na. Searches a reaction suitable for currentEvent , starting with the current innermost state and \nmoving outward until a state defining a reaction fo r the event is found. Returns \nsimple_state<>::forward_event() if no reaction has been found \nb. Executes the found reaction. If the reaction resu lt is equal to the return value of \nsimple_state<>::forward_event() then resumes the reaction search (step a). Returns the \nreaction result otherwise \n5. Constructs a function object exceptionEventHandler returning result and accepting an exception \nevent parameter that processes the passed exception event, with the following differences to the proce ssing \nof normal events: \n/circle6From the moment when the exception has been thrown until right after the execution of the exception \nevent reaction, states that need to be exited are o nly destructed but no exit member functions are \ncalled \n/circle6If the state machine is stable when the exception e vent is processed then exception event reaction \nsearch starts with the innermost state that was las t visited during the last normal event reaction sea rch \n(the exception event was generated as a result of t his normal reaction search) \n/circle6If the state machine is unstable when the exception event is processed then excepti on event reaction \nsearch starts with the outermost unstable state \n/circle6As for normal events, reaction search moves outward when the current state cannot handle the event. Page 8 of 35 The Boost Statechart Library - Reference \n2008/01/06However, if there is no outer state (an outermost state has been reached) the reaction search is \nconsidered unsuccessful. That is, exception events will never be dispatched to orthogonal regions \nother than the one that caused the exception event \n/circle6Should an exception be thrown during exception even t reaction search or reaction execution then the \nexception is propagated out of the exceptionEventHandler function object (that is, \nExceptionTranslator is not used to translate exceptions thrown while processi ng an exception \nevent) \n/circle6If no reaction could be found for the exception eve nt or if the state machine is not stable after \nprocessing the exception event, the original except ion is rethrown. Otherwise, a result object is \nreturned equal to the one returned by simple_state<>::discard_event() \n6. Passes action and exceptionEventHandler to ExceptionTranslator::operator()() . If \nExceptionTranslator::operator()() throws an exception, the exception is propagated t o the \ncaller. If the caller catches the exception, the cu rrently active outermost state and all its direct a nd indirect \ninner states are destructed. Innermost states are d estructed first. Other states are destructed as soo n as all \ntheir direct and indirect inner states have been de structed. The inner states of each state are destru cted \naccording to the number of their orthogonal region. The state in the orthogonal region with the highes t \nnumber is always destructed first, then the state i n the region with the second-highest number and so on. \nOtherwise continues with step 7 \n7. If the return value of ExceptionTranslator::operator()() is equal to the one of \nsimple_state<>::forward_event() then continues with step 3 \n8. If the return value of ExceptionTranslator::operator()() is equal to the one of \nsimple_state<>::defer_event() then the return value of \ncurrentEvent. intrusive_from_this () is stored in a state- specific queue. Continues with step 11 \n9. If the return value of ExceptionTranslator::operator()() is equal to the one of \nsimple_state<>::discard_event() then continues with step 11 \n10. Calls static_cast< MostDerived * >( this )->unconsumed_ev ent \n( currentEvent ) . If unconsumed_event() throws an exception, the exception is propagated t o \nthe caller. Such an exception never leads to the de struction of any states (in contrast to exceptions \npropagated from ExceptionTranslator::operator()() ) \n11. If the posted events queue is non-empty then deq ueues the first event, selects it as currentEvent and \ncontinues with step 2. Returns to the caller otherw ise \nThrows : Any exceptions propagated from MostDerived::unconsumed_event() or \nExceptionTranslator::operator() . Exceptions never originate in the library itself but only in code \nsupplied through template parameters: \n/circle6Allocator::rebind<>::other::allocate() \n/circle6state constructors \n/circle6react member functions \n/circle6exit member functions \n/circle6transition-actions \n/circle6MostDerived::unconsumed_event() \nvoid post_event( \n const intrusive_ptr< const event_base > & ); \nEffects : Pushes the passed event into the posted events qu eue \nThrows : Any exceptions propagated from Allocator::allocate() \nvoid post_event( const event_base & evt ); \nEffects : post_event( evt.intrusive_from_this() ); \nThrows : Any exceptions propagated from Allocator::allocate() \nvoid unconsumed_event( const event_base & evt ); \nEffects : None \nNote : This function (or, if present, the equally named derived class member function) is called by process_event () \nwhenever a dispatched event did not trigger a react ion, see process_event () effects, point 10 for more information. Page 9 of 35 The Boost Statechart Library - Reference \n2008/01/06Class template state_machine observer functions \nbool terminated() const; \nReturns : true , if the machine is terminated. Returns false otherwise \nNote : Is equivalent to state_begin() == state_end() \ntemplate< class Target > \nTarget state_cast() const; \nReturns : Depending on the form of Target either a reference or a pointer to const if at least one of the \ncurrently active states can successfully be dynamic_cast to Target . Returns 0 for pointer targets and throws \nstd::bad_cast for reference targets otherwise. Target can take either of the following forms: const \nClass * or const Class & \nThrows : std::bad_cast if Target is a reference type and none of the active states can be dynamic_cast \nto Target \nNote : The search sequence is the same as for process_event () \ntemplate< class Target > \nTarget state_downcast() const; \nRequires : For reference targets the compiler must support p artial specialization of class templates, otherwise a \ncompile-time error will result. The type denoted by Target must be a model of the SimpleState or State concepts \nReturns : Depending on the form of Target either a reference or a pointer to const if Target is equal to the \nmost-derived type of a currently active state. Retu rns 0 for pointer targets and throws std::bad_cast for \nreference targets otherwise. Target can take either of the following forms: const Class * or const \nClass & \nThrows : std::bad_cast if Target is a reference type and none of the active states has a most derived type \nequal to Target \nNote : The search sequence is the same as for process_event () \nstate_iterator state_begin() const; \nstate_iterator state_end() const; \nReturn : Iterator objects, the range [ state_begin() , state_end() ) refers to all currently active innermost \nstates . For an object i of type state_iterator , *i returns a const state_base_type & and \ni.operator->() returns a const state_base_type * \nNote : The position of a given innermost state in the ra nge is arbitrary. It may change with each call to a modifier \nfunction. Moreover, all iterators are invalidated w henever a modifier function is called \nHeader <boost/statechart/ \nasynchronous_state_machine.hpp> \nClass template asynchronous_state_machine \nThis is the base class template of all asynchronous state machines. \nClass template asynchronous_state_machine parameters \nTemplate parameter Requirements Semantics Default \nMostDerived The most-derived subtype of \nthis class template \nA model of the SimpleState or \nState concepts. The Context Page 10 of 35 The Boost Statechart Library - Reference \n2008/01/06Class template asynchronous_state_machine synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< \n class MostDerived, \n class InitialState, \n class Scheduler = fifo_scheduler<>, \n class Allocator = std::allocator< void >, \n class ExceptionTranslator = null_exception_tran slator > \n class asynchronous_state_machine : \n public state_machine< \n MostDerived, InitialState, Allocator, Excepti onTranslator >, \n public event_processor< Scheduler > \n { \n protected: \n typedef asynchronous_state_machine my_base; \n \n asynchronous_state_machine( \n typename event_processor< Scheduler >::my_c ontext ctx ); \n ~asynchronous_state_machine(); \n }; \n} \n} \nClass template asynchronous_state_machine constructor and destructor \nasynchronous_state_machine( \n typename event_processor< Scheduler >::my_context ctx ); \nEffects : Constructs a non-running asynchronous state machi ne \nNote : Users cannot create asynchronous_state_machine<> subtype objects directly. This can only be \ndone through an object of the Scheduler class \n~asynchronous_state_machine(); \nEffects : Destructs the state machine \nNote : Users cannot destruct asynchronous_state_machine<> subtype objects directly. This can only be \ndone through an object of the Scheduler class InitialState argument passed to the \nsimple_state<> or state<> \nbase of InitialState must \nbe MostDerived . That is, \nInitialState must be an \noutermost state of this state \nmachine The state that is \nentered when the state \nmachine is initiated \nthrough the Scheduler \nobject \nScheduler A model of the Scheduler \nconcept see Scheduler concept fifo_scheduler<> \nAllocator A model of the standard \nAllocator concept std::allocator< void > \nExceptionTranslator A model of the \nExceptionTranslator concept see \nExceptionTranslator \nconcept null_exception_translator Page 11 of 35 The Boost Statechart Library - Reference \n2008/01/06Header <boost/statechart/ event_processor.hpp > \nClass template event_processor \nThis is the base class template of all types that p rocess events. asynchronous_state_machine<> is just \none possible event processor implementation. \nClass template event_processor parameters \nClass template event_processor synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class Scheduler > \n class event_processor \n { \n public: \n virtual ~event_processor (); \n \n Scheduler & my_scheduler () const; \n \n typedef typename Scheduler::processor_handle \n processor_handle; \n processor_handle my_handle () const; \n \n void initiate (); \n void process_event ( const event_base & evt ); \n void terminate (); \n \n protected: \n typedef const typename Scheduler::processor_c ontext & \n my_context; \n event_processor ( my_context ctx ); \n \n private: \n virtual void initiate_impl() = 0; \n virtual void process_event_impl( \n const event_base & evt ) = 0; \n virtual void terminate_impl() = 0; \n }; \n} \n} \nClass template event_processor constructor and destructor \nevent_processor( my_context ctx ); \nEffects : Constructs an event processor object and stores c opies of the reference returned by \nmyContext.my_scheduler() and the object returned by myContext.my_handle() \nNote : Users cannot create event_processor<> subtype objects directly. This can only be done th rough an \nobject of the Scheduler class Template parameter Requirements Semantics \nScheduler A model of the Scheduler concept see Scheduler concept Page 12 of 35 The Boost Statechart Library - Reference \n2008/01/06virtual ~event_processor(); \nEffects : Destructs an event processor object \nNote : Users cannot destruct event_processor<> subtype objects directly. This can only be done th rough an \nobject of the Scheduler class \nClass template event_processor modifier functions \nvoid initiate(); \nEffects : initiate_impl(); \nThrows : Any exceptions propagated from the implementation of initiate_impl() \nvoid process_event( const event_base & evt ); \nEffects : process_event_impl( evt ); \nThrows : Any exceptions propagated from the implementation of process_event_impl() \nvoid terminate(); \nEffects : terminate_impl(); \nThrows : Any exceptions propagated from the implementation of terminate_impl() \nClass template event_processor observer functions \nScheduler & my_scheduler() const; \nReturns : The Scheduler reference obtained in the constructor \nprocessor_handle my_handle() const; \nReturns : The processor_handle object obtained in the constructor \nHeader <boost/statechart/fifo_scheduler.hpp> \nClass template fifo_scheduler \nThis class template is a model of the Scheduler concept. \nClass template fifo_scheduler parameters \nClass template fifo_scheduler synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< Template \nparameter Requirements Semantics Default \nFifoWorker A model of the FifoWorker concept see FifoWorker \nconcept fifo_worker<> \nAllocator A model of the standard Allocator \nconcept std::allocator< void > Page 13 of 35 The Boost Statechart Library - Reference \n2008/01/06 class FifoWorker = fifo_worker<>, \n class Allocator = std::allocator< void > > \n class fifo_scheduler : noncopyable \n { \n public: \n fifo_scheduler ( bool waitOnEmptyQueue = false ); \n \n typedef implementation-defined processor_handle; \n \n class processor_context : noncopyable \n { \n processor_context( \n fifo_scheduler & scheduler, \n const processor_handle & theHandle ); \n \n fifo_scheduler & my_scheduler() const; \n const processor_handle & my_handle() const; \n \n friend class fifo_scheduler; \n friend class event_processor< fifo_schedule r >; \n }; \n \n template< class Processor > \n processor_handle create_processor (); \n template< class Processor, typename Param1 > \n processor_handle create_processor ( Param1 param1 ); \n \n // More create_processor overloads \n \n void destroy_processor ( processor_handle processor ); \n \n void initiate_processor ( processor_handle processor ); \n void terminate_processor ( processor_handle processor ); \n \n typedef intrusive_ptr< const event_base > eve nt_ptr_type; \n \n void queue_event ( \n const processor_handle & processor, \n const event_ptr_type & pEvent ); \n \n typedef typename FifoWorker::work_item work_i tem; \n \n void queue_work_item ( const work_item & item ); \n \n void terminate (); \n bool terminated () const; \n \n unsigned long operator() ( \n unsigned long maxEventCount = 0 ); \n }; \n} \n} \nClass template fifo_scheduler constructor \nfifo_scheduler( bool waitOnEmptyQueue = false ); \nEffects : Constructs a fifo_scheduler<> object. In multi-threaded builds, waitOnEmptyQueue is \nforwarded to the constructor of a data member of ty pe FifoWorker . In single-threaded builds, the \nFifoWorker data member is default-constructed \nNote : In single-threaded builds the fifo_scheduler<> constructor does not accept any parameters and Page 14 of 35 The Boost Statechart Library - Reference \n2008/01/06operator()() thus always returns to the caller when the event q ueue is empty \nClass template fifo_scheduler modifier functions \ntemplate< class Processor > \nprocessor_handle create_processor(); \nRequires : The Processor type must be a direct or indirect subtype of the event_processor class template \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \nthe constructor of Processor , passing an appropriate processor_context object as the only argument \nReturns : A processor_handle object that henceforth identifies the created even t processor object \nThrows : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nCaution : The current implementation of this function makes an (indirect) call to global operator new() . \nUnless global operator new() is replaced, care must be taken when to call this function in applications with \nhard real-time requirements \ntemplate< class Processor, typename Param1 > \nprocessor_handle create_processor( Param1 param1 ); \nRequires : The Processor type must be a direct or indirect subtype of the event_processor class template \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \nthe constructor of Processor , passing an appropriate processor_context object and param1 as \narguments \nReturns : A processor_handle object that henceforth identifies the created even t processor object \nThrows : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nNote : boost::ref() and boost::cref() can be used to pass arguments by reference rather than by copy. \nfifo_scheduler<> has 5 additional create_processor<> overloads, allowing to pass up to 6 custom \narguments to the constructors of event processors \nCaution : The current implementation of this and all other overloads make (indirect) calls to global operator \nnew() . Unless global operator new() is replaced, care must be taken when to call these overloads in \napplications with hard real-time requirements \nvoid destroy_processor( processor_handle processor ); \nRequires : processor was obtained from a call to one of the create_processor<>() overloads on the \nsame fifo_scheduler<> object \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \nthe destructor of the event processor object associ ated with processor . The object is silently discarded if the \nevent processor object has been destructed before \nThrows : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nCaution : The current implementation of this function leads to an (indirect) call to global operator delete() \n(the call is made when the last processor_handle object associated with the event processor object is \ndestructed). Unless global operator delete() is replaced, care must be taken when to call this function in \napplications with hard real-time requirements \nvoid initiate_processor( processor_handle processor ); \nRequires : processor was obtained from a call to one of the create_processor() overloads on the same \nfifo_scheduler<> object \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \ninitiate () on the event processor object associated with processor . The object is silently discarded if the \nevent processor object has been destructed before Page 15 of 35 The Boost Statechart Library - Reference \n2008/01/06Throws : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nvoid terminate_processor( processor_handle processo r ); \nRequires : processor was obtained from a call to one of the create_processor<>() overloads on the \nsame fifo_scheduler<> object \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \nterminate () on the event processor object associated with processor . The object is silently discarded if the \nevent processor object has been destructed before \nThrows : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nvoid queue_event( \n const processor_handle & processor, \n const event_ptr_type & pEvent ); \nRequires : pEvent.get() != 0 and processor was obtained from a call to one of the \ncreate_processor<>() overloads on the same fifo_scheduler<> object \nEffects : Creates and passes to FifoWorker::queue_work_item() an object of type \nFifoWorker::work_item that, when later executed in FifoWorker::operator()() , leads to a call to \nprocess_event ( *pEvent ) on the event processor object associated with processor . The object is \nsilently discarded if the event processor object ha s been destructed before \nThrows : Any exceptions propagated from FifoWorker::work_item() and \nFifoWorker::queue_work_item() \nvoid queue_work_item( const work_item & item ); \nEffects : FifoWorker::queue_work_item( item ); \nThrows : Any exceptions propagated from the above call \nvoid terminate(); \nEffects : FifoWorker::terminate() \nThrows : Any exceptions propagated from the above call \nunsigned long operator()( unsigned long maxEventCou nt = 0 ); \nRequires : Must only be called from exactly one thread \nEffects : FifoWorker::operator()( maxEventCount ) \nReturns : The return value of the above call \nThrows : Any exceptions propagated from the above call \nClass template fifo_scheduler observer functions \nbool terminated() const; \nRequires : Must only be called from the thread that also cal ls operator()() \nReturns : FifoWorker::terminated(); \nHeader <boost/statechart/exception_translator.hpp> \nClass template exception_translator \nThis class template is a model of the ExceptionTranslator concept. Page 16 of 35 The Boost Statechart Library - Reference \n2008/01/06Class template exception_translator parameters \nClass template exception_translator synopsis & semantics \nnamespace boost \n{ \nnamespace statechart \n{ \n class exception_thrown : public event< exception_ thrown > {}; \n \n template< class ExceptionEvent = exception_thrown > \n class exception_translator \n { \n public: \n template< class Action, class ExceptionEventH andler > \n result operator()( \n Action action, \n ExceptionEventHandler eventHandler ) \n { \n try \n { \n return action(); \n } \n catch( ... ) \n { \n return eventHandler( ExceptionEvent() ); \n } \n } \n }; \n} \n} \nHeader <boost/statechart/ \nnull_exception_translator.hpp> \nClass null_exception_translator \nThis class is a model of the ExceptionTranslator concept. \nClass null_exception_translator synopsis & semantics \nnamespace boost \n{ \nnamespace statechart \n{ \n class null_exception_translator \n { \n public: \n template< class Action, class ExceptionEventH andler > \n result operator()( \n Action action, ExceptionEventHandler ) Template \nparameter Requirements Semantics Default \nExceptionEvent A model of the Event \nconcept The type of event that is dispatched when an \nexception is propagated into the framework exception_thrown Page 17 of 35 The Boost Statechart Library - Reference \n2008/01/06 { \n return action(); \n } \n }; \n} \n} \nHeader <boost/statechart/simple_state.hpp> \nEnum history_mode \nDefines the history type of a state. \nnamespace boost \n{ \nnamespace statechart \n{ \n enum history_mode \n { \n has_no_history, \n has_shallow_history, \n has_deep_history, \n has_full_history // shallow & deep \n }; \n} \n} \nClass template simple_state \nThis is the base class template for all models of t he SimpleState concept. Such models must not call any of the \nfollowing simple_state<> member functions from their constructors: \nvoid post_event ( \n const intrusive_ptr< const event_base > & ); \nvoid post_event ( const event_base & ); \n \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_shallow_history (); \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_deep_history (); \n \noutermost_context_type & outermost_context (); \nconst outermost_context_type & outermost_context () const; \n \ntemplate< class OtherContext > \nOtherContext & context (); \ntemplate< class OtherContext > \nconst OtherContext & context () const; \n \ntemplate< class Target > \nTarget state_cast () const; \ntemplate< class Target > \nTarget state_downcast () const; Page 18 of 35 The Boost Statechart Library - Reference \n2008/01/06 \nstate_iterator state_begin () const; \nstate_iterator state_end () const; \nStates that need to call any of these member functi ons from their constructors must derive from the state class \ntemplate. \nClass template simple_state parameters \nClass template simple_state synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< \n class MostDerived, \n class Context, \n class InnerInitial = unspecified , \n history_mode historyMode = has_no_history > \n class simple_state : implementation-defined \n { \n public: \n // by default, a state has no reactions \n typedef mpl::list<> reactions; \n \n // see template parameters \n template< implementation-defined-unsigned-integer-type \n innerOrthogonalPosition > \n struct orthogonal Template \nparameter Requirements Semantics Default \nMostDerived The most-derived subtype of this class template \nContext A most-derived direct or indirect subtype of the \nstate_machine or asynchronous_state_machine class \ntemplates or a model of the SimpleState or State concepts or \nan instantiation of the simple_state<>::orthogonal class \ntemplate. Must be a complete type Defines the \nstates' position \nin the state \nhierarchy \nInnerInitial An mpl::list<> containing models of the SimpleState or \nState concepts or instantiations of the shallow_history or \ndeep_history class templates. If there is only a single inner \ninitial state that is not a template instantiation then it can also \nbe passed directly, without wrapping it into an mpl::list<> . \nThe Context argument passed to the simple_state<> or \nstate<> base of each state in the list must correspond to the \northogonal region it belongs to. That is, the first state in the \nlist must pass MostDerived::orthogonal< 0 > , the second \nMostDerived::orthogonal< 1 > and so forth. \nMostDerived::orthogonal< 0 > and MostDerived are \nsynonymous Defines the \ninner initial \nstate for each \northogonal \nregion. By \ndefault, a state \ndoes not have \ninner states unspecified \nhistoryMode One of the values defined in the history_mode enumeration Defines \nwhether the \nstate saves \nshallow, deep \nor both \nhistories upon \nexit has_no_history Page 19 of 35 The Boost Statechart Library - Reference \n2008/01/06 { \n // implementation-defined \n }; \n \n typedef typename Context::outermost_context_t ype \n outermost_context_type; \n \n outermost_context_type & outermost_context (); \n const outermost_context_type & outermost_context () const; \n \n template< class OtherContext > \n OtherContext & context (); \n template< class OtherContext > \n const OtherContext & context () const; \n \n template< class Target > \n Target state_cast () const; \n template< class Target > \n Target state_downcast () const; \n \n // a model of the StateBase concept \n typedef implementation-defined state_base_type; \n // a model of the standard Forward Iterator c oncept \n typedef implementation-defined state_iterator; \n \n state_iterator state_begin () const; \n state_iterator state_end () const; \n \n void post_event ( \n const intrusive_ptr< const event_base > & ); \n void post_event ( const event_base & ); \n \n result discard_event (); \n result forward_event (); \n result defer_event (); \n template< class DestinationState > \n result transit (); \n template< \n class DestinationState, \n class TransitionContext, \n class Event > \n result transit ( \n void ( TransitionContext::* )( const Event & ), \n const Event & ); \n result terminate (); \n \n template< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \n void clear_shallow_history (); \n template< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \n void clear_deep_history (); \n \n static id_type static_type (); \n \n template< class CustomId > \n static const CustomId * custom_static_type_ptr (); Page 20 of 35 The Boost Statechart Library - Reference \n2008/01/06 \n template< class CustomId > \n static void custom_static_type_ptr ( const CustomId * ); \n \n // see transit () or terminate () effects \n void exit() {} \n \n protected: \n simple_state (); \n ~simple_state (); \n }; \n} \n} \nClass template simple_state constructor and destructor \nsimple_state(); \nEffects : Constructs a state object \n~simple_state(); \nEffects : Pushes all events deferred by the state into the posted events queue \nClass template simple_state modifier functions \nvoid post_event( \n const intrusive_ptr< const event_base > & pEvt ); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template . All direct and indirect callers must be exception- neutral \nEffects : outermost_context (). post_event ( pEvt ); \nThrows : Whatever the above call throws \nvoid post_event( const event_base & evt ); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template . All direct and indirect callers must be exception- neutral \nEffects : outermost_context (). post_event ( evt ); \nThrows : Whatever the above call throws \nresult discard_event(); \nRequires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : Instructs the state machine to discard the curren t event and to continue with the processing of the \nremaining events (see state_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nresult forward_event(); \nRequires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : Instructs the state machine to forward the curren t event to the next state (see \nstate_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nresult defer_event(); Page 21 of 35 The Boost Statechart Library - Reference \n2008/01/06Requires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : Instructs the state machine to defer the current event and to continue with the processing of the re maining \nevents (see state_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nThrows : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template \nparameter passed to the base class of outermost_context_type ) \ntemplate< class DestinationState > \nresult transit(); \nRequires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : \n1. Exits all currently active direct and indirect in ner states of the innermost common context of this state and \nDestinationState . Innermost states are exited first. Other states a re exited as soon as all their direct \nand indirect inner states have been exited. The inn er states of each state are exited according to the number \nof their orthogonal region. The state in the orthog onal region with the highest number is always exite d first, \nthen the state in the region with the second-highes t number and so on. \nThe process of exiting a state consists of the foll owing steps: \n1. If there is an exception pending that has not yet b een handled successfully then only step 5 is execut ed \n2. Calls the exit member function (see synopsis ) of the most-derived state object. If exit() throws \nthen steps 3 and 4 are not executed \n3. If the state has shallow history then shallow his tory information is saved \n4. If the state is an innermost state then deep hist ory information is saved for all direct and indirec t outer \nstates that have deep history \n5. The state object is destructed \n2. Enters (constructs) the state that is both a dire ct inner state of the innermost common context and either the \nDestinationState itself or a direct or indirect outer state of DestinationState \n3. Enters (constructs) the tree formed by the direct and indirect inner states of the previously entere d state \ndown to the DestinationState and beyond depth first. The inner states of each s tate are entered \naccording to the number of their orthogonal region. The state in orthogonal region 0 is always entered first, \nthen the state in region 1 and so on \n4. Instructs the state machine to discard the curren t event and to continue with the processing of the remaining \nevents (see state_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nThrows : Any exceptions propagated from: \n/circle6Allocator::rebind<>::other::allocate() (the template parameter passed to the base class o f \noutermost_context_type ) \n/circle6state constructors \n/circle6exit member functions \nCaution : Inevitably destructs this state before returning to the calling react member function, which must \ntherefore not attempt to access anything except sta ck objects before returning to its caller \ntemplate< \n class DestinationState, \n class TransitionContext, \n class Event > \nresult transit( \n void ( TransitionContext::* )( const Event & ), \n const Event & ); \nRequires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : Page 22 of 35 The Boost Statechart Library - Reference \n2008/01/061. Exits all currently active direct and indirect in ner states of the innermost common context of this state and \nDestinationState . Innermost states are exited first. Other states a re exited as soon as all their direct \nand indirect inner states have been exited. The inn er states of each state are exited according to the number \nof their orthogonal region. The state in the orthog onal region with the highest number is always exite d first, \nthen the state in the region with the second-highes t number and so on. \nThe process of exiting a state consists of the foll owing steps: \n1. If there is an exception pending that has not yet b een handled successfully then only step 5 is execut ed \n2. Calls the exit member function (see synopsis ) of the most-derived state object. If exit() throws \nthen steps 3 and 4 are not executed \n3. If the state has shallow history then shallow his tory information is saved \n4. If the state is an innermost state then deep hist ory information is saved for all direct and indirec t outer \nstates that have deep history \n5. The state object is destructed \n2. Executes the passed transition action, forwarding the passed event \n3. Enters (constructs) the state that is both a dire ct inner state of the innermost common context and either the \nDestinationState itself or a direct or indirect outer state of DestinationState \n4. Enters (constructs) the tree formed by the direct and indirect inner states of the previously entere d state \ndown to the DestinationState and beyond depth first. The inner states of each s tate are entered \naccording to the number of their orthogonal region. The state in orthogonal region 0 is always entered first, \nthen the state in region 1 and so on \n5. Instructs the state machine to discard the curren t event and to continue with the processing of the remaining \nevents (see state_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nThrows : Any exceptions propagated from: \n/circle6Allocator::rebind<>::other::allocate() (the template parameter passed to the base class o f \noutermost_context_type ) \n/circle6state constructors \n/circle6exit member functions \n/circle6the transition action \nCaution : Inevitably destructs this state before returning to the calling react member function, which must \ntherefore not attempt to access anything except sta ck objects before returning to its caller \nresult terminate(); \nRequires : Must only be called from within react member functions, which are called by \ncustom_reaction<> instantiations. All direct and indirect callers mu st be exception-neutral \nEffects : Exits this state and all its direct and indirect inner states. Innermost states are exited first. Ot her states are \nexited as soon as all their direct and indirect inn er states have been exited. The inner states of eac h state are exited \naccording to the number of their orthogonal region. The state in the orthogonal region with the highes t number is \nalways exited first, then the state in the region w ith the second-highest number and so on. \nThe process of exiting a state consists of the foll owing steps: \n1. If there is an exception pending that has not yet been handled successfully then only step 5 is exec uted \n2. Calls the exit member function (see synopsis ) of the most-derived state object. If exit() throws then \nsteps 3 and 4 are not executed \n3. If the state has shallow history then shallow his tory information is saved \n4. If the state is an innermost state then deep hist ory information is saved for all direct and indirec t outer states \nthat have deep history \n5. The state object is destructed \nAlso instructs the state machine to discard the cur rent event and to continue with the processing of t he remaining \nevents (see state_machine<>::process_event () for details) \nReturns : A result object. The user-supplied react member function must return this object to its cal ler \nThrows : Any exceptions propagated from: \n/circle6Allocator::rebind<>::other::allocate() (the template parameter passed to the base class o f \noutermost_context_type , used to allocate space to save history) \n/circle6exit member functions Page 23 of 35 The Boost Statechart Library - Reference \n2008/01/06Note : If this state is the only currently active inner state of its direct outer state then the direct out er state is \nterminated also. The same applies recursively for a ll indirect outer states \nCaution : Inevitably destructs this state before returning to the calling react member function, which must \ntherefore not attempt to access anything except sta ck objects before returning to its caller \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_shallow_history(); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. The historyMode argument passed to the \nsimple_state<> or state<> base of HistoryContext must be equal to has_shallow_history or \nhas_full_history \nEffects : Clears the shallow history of the orthogonal regi on specified by orthogonalPosition of the state \nspecified by HistoryContext \nThrows : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template \nparameter passed to the base class of outermost_context_type ) \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_deep_history(); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. The historyMode argument passed to the \nsimple_state<> or state<> base of HistoryContext must be equal to has_deep_history or \nhas_full_history \nEffects : Clears the deep history of the orthogonal region specified by orthogonalPosition of the state \nspecified by HistoryContext \nThrows : Any exceptions propagated from Allocator::rebind<>::other::allocate() (the template \nparameter passed to the base class of outermost_context_type ) \nClass template simple_state observer functions \noutermost_context_type & outermost_context(); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. If called from a destructor of a d irect or indirect subtype then the \nstate_machine<> subclass portion must still exist \nReturns : A reference to the outermost context, which is al ways the state machine this state belongs to \nconst outermost_context_type & outermost_context() const; \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. If called from a destructor of a d irect or indirect subtype then the \nstate_machine<> subclass portion must still exist \nReturns : A reference to the const outermost context, which is always the state machine this state belongs to \ntemplate< class OtherContext > \nOtherContext & context(); \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. If called from a destructor of a d irect or indirect subtype with a \nstate_machine<> subtype as argument then the state_machine<> subclass portion must still exist \nReturns : A reference to a direct or indirect context \ntemplate< class OtherContext > Page 24 of 35 The Boost Statechart Library - Reference \n2008/01/06const OtherContext & context() const; \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. If called from a destructor of a d irect or indirect subtype with a \nstate_machine<> subtype as argument then the state_machine<> subclass portion must still exist \nReturns : A reference to a const direct or indirect context \ntemplate< class Target > \nTarget state_cast() const; \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template \nReturns : Has exactly the same semantics as state_machine<>::state_cast <>() \nThrows : Has exactly the same semantics as state_machine<>::state_cast <>() \nNote : The result is unspecified if this function is called when the machine is unstable \ntemplate< class Target > \nTarget state_downcast() const; \nRequires : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template. Moreover, state_machine<>::state_downcast <>() \nrequirements also apply \nReturns : Has exactly the same semantics as state_machine<>::state_downcast <>() \nThrows : Has exactly the same semantics as state_machine<>::state_downcast <>() \nNote : The result is unspecified if this function is called when the machine is unstable \nstate_iterator state_begin() const; \nstate_iterator state_end() const; \nRequire : If called from a constructor of a direct or indir ect subtype then the most-derived type must directl y or \nindirectly derive from the state class template \nReturn : Have exactly the same semantics as state_machine<>::state_begin () and \nstate_machine<>::state_end () \nNote : The result is unspecified if these functions are called when the machine is unstable \nClass template simple_state static functions \nstatic id_type static_type(); \nReturns : A value unambiguously identifying the type of MostDerived \nNote : id_type values are comparable with operator==() and operator!=() . An unspecified collating \norder can be established with std::less< id_type > \ntemplate< class CustomId > \nstatic const CustomId * custom_static_type_ptr(); \nRequires : If a custom type identifier has been set then CustomId must match the type of the previously set \npointer \nReturns : The pointer to the custom type identifier for MostDerived or 0 \nNote : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined \ntemplate< class CustomId > \nstatic void custom_static_type_ptr( const CustomId * ); \nEffects : Sets the pointer to the custom type identifier fo r MostDerived \nNote : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined Page 25 of 35 The Boost Statechart Library - Reference \n2008/01/06Header <boost/statechart/ state.hpp > \nClass template state \nThis is the base class template for all models of t he State concept. Such models typically need to call at lea st one of \nthe following simple_state<> member functions from their constructors: \nvoid post_event ( \n const intrusive_ptr< const event_base > & ); \nvoid post_event ( const event_base & ); \n \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_shallow_history (); \ntemplate< \n class HistoryContext, \n implementation-defined-unsigned-integer-type \n orthogonalPosition > \nvoid clear_deep_history (); \n \noutermost_context_type & outermost_context (); \nconst outermost_context_type & outermost_context () const; \n \ntemplate< class OtherContext > \nOtherContext & context (); \ntemplate< class OtherContext > \nconst OtherContext & context () const; \n \ntemplate< class Target > \nTarget state_cast () const; \ntemplate< class Target > \nTarget state_downcast () const; \n \nstate_iterator state_begin () const; \nstate_iterator state_end () const; \nStates that do not need to call any of these member functions from their constructors should rather de rive from the \nsimple_state class template, what saves the implementation of t he forwarding constructor. \nClass template state synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< \n class MostDerived, \n class Context, \n class InnerInitial = unspecified , \n history_mode historyMode = has_no_history > \n class state : public simple_state< \n MostDerived, Context, InnerInitial, historyMode > \n { \n protected: \n struct my_context \n { \n // implementation-defined Page 26 of 35 The Boost Statechart Library - Reference \n2008/01/06 }; \n \n typedef state my_base; \n \n state( my_context ctx ); \n ~state(); \n }; \n} \n} \nDirect and indirect subtypes of state<> must provide a constructor with the same signature as the state<> \nconstructor, forwarding the context parameter. \nHeader <boost/statechart/shallow_history.hpp> \nClass template shallow_history \nThis class template is used to specify a shallow hi story transition target or a shallow history inner initial state. \nClass template shallow_history parameters \nClass template shallow_history synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class DefaultState > \n class shallow_history \n { \n // implementation-defined \n }; \n} \n} \nHeader <boost/statechart/deep_history.hpp> \nClass template deep_history \nThis class template is used to specify a deep histo ry transition target or a deep history inner initia l state. The \ncurrent deep history implementation has some limitations . \nClass template deep_history parameters Template \nparameter Requirements Semantics \nDefaultState A model of the SimpleState or State concepts. The type passed as \nContext argument to the simple_state<> or state<> base \nof DefaultState must itself pass has_shallow_history or \nhas_full_history as historyMode argument to its simple_state<> or \nstate<> base The state that is \nentered if shallow \nhistory is not \navailable \nTemplate \nparameter Requirements Semantics Page 27 of 35 The Boost Statechart Library - Reference \n2008/01/06Class template deep_history synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class DefaultState > \n class deep_history \n { \n // implementation-defined \n }; \n} \n} \nHeader <boost/statechart/event_base.hpp> \nClass event_base \nThis is the common base of all events. \nClass event_base synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n class event_base \n { \n public: \n intrusive_ptr< const event_base > \n intrusive_from_this () const; \n \n typedef implementation-defined id_type; \n \n id_type dynamic_type () const; \n \n template< typename CustomId > \n const CustomId * custom_dynamic_type_ptr () const; \n \n protected: \n event_base ( unspecified-parameter ); \n virtual ~event_base (); \n }; \n} \n} \nClass event_base constructor and destructor \nevent_base( unspecified-parameter ); \nEffects : Constructs the common base portion of an event DefaultState A model of the SimpleState or State concepts. The type passed as \nContext argument to the simple_state<> or state<> base \nof DefaultState must itself pass has_deep_history or \nhas_full_history as historyMode argument to its simple_state<> or \nstate<> base The state that is \nentered if deep \nhistory is not \navailable Page 28 of 35 The Boost Statechart Library - Reference \n2008/01/06virtual ~event_base(); \nEffects : Destructs the common base portion of an event \nClass event_base observer functions \nintrusive_ptr< const event_base > intrusive_from_th is() const; \nReturns : Another intrusive_ptr< const event_base > referencing this if this is already \nreferenced by an intrusive_ptr<> . Otherwise, returns an intrusive_ptr< const event_base > \nreferencing a newly created copy of the most-derive d object \nid_type dynamic_type() const; \nReturns : A value unambiguously identifying the most-derive d type \nNote : id_type values are comparable with operator==() and operator!=() . An unspecified collating \norder can be established with std::less< id_type > . In contrast to typeid( cs ) , this function is \navailable even on platforms that do not support C++ RTTI (or have been configured to not support it) \ntemplate< typename CustomId > \nconst CustomId * custom_dynamic_type_ptr() const; \nRequires : If a custom type identifier has been set then CustomId must match the type of the previously set \npointer \nReturns : A pointer to the custom type identifier or 0 \nNote : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined \nHeader <boost/statechart/event.hpp> \nClass template event \nThis is the base class template of all events. \nClass template event parameters \nClass template event synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class MostDerived, class Allocator = st d::allocator< void > > \n class event : implementation-defined \n { \n public: \n static void * operator new ( std::size_t size ); Template \nparameter Requirements Semantics Default \nMostDerived The most-derived \nsubtype of this class \ntemplate \nAllocator A model of the \nstandard Allocator \nconcept Allocator::rebind< MostDerived >::other is \nused to allocate and deallocate all event subtype \nobjects of dynamic storage duration, see operator \nnew std::allocator< \nvoid > Page 29 of 35 The Boost Statechart Library - Reference \n2008/01/06 static void operator delete ( void * pEvent ); \n \n static id_type static_type (); \n \n template< class CustomId > \n static const CustomId * custom_static_type_ptr (); \n \n template< class CustomId > \n static void custom_static_type_ptr ( const CustomId * ); \n \n protected: \n event (); \n virtual ~event (); \n }; \n} \n} \nClass template event constructor and destructor \nevent(); \nEffects : Constructs an event \nvirtual ~event(); \nEffects : Destructs an event \nClass template event static functions \nstatic void * operator new( std::size_t size ); \nEffects : Allocator::rebind< MostDerived >::other().allocate( 1, static_cast< \nMostDerived * >( 0 ) ); \nReturns : The return value of the above call \nThrows : Whatever the above call throws \nstatic void operator delete( void * pEvent ); \nEffects : Allocator::rebind< MostDerived >::other().deallocat e( static_cast< \nMostDerived * >( pEvent ), 1 ); \nstatic id_type static_type(); \nReturns : A value unambiguously identifying the type of MostDerived \nNote : id_type values are comparable with operator==() and operator!=() . An unspecified collating \norder can be established with std::less< id_type > \ntemplate< class CustomId > \nstatic const CustomId * custom_static_type_ptr(); \nRequires : If a custom type identifier has been set then CustomId must match the type of the previously set \npointer \nReturns : The pointer to the custom type identifier for MostDerived or 0 \nNote : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined \ntemplate< class CustomId > \nstatic void custom_static_type_ptr( const CustomId * ); \nEffects : Sets the pointer to the custom type identifier fo r MostDerived Page 30 of 35 The Boost Statechart Library - Reference \n2008/01/06Note : This function is not available if BOOST_STATECHART_USE_NATIVE_RTTI is defined \nHeader <boost/statechart/transition.hpp> \nClass template transition \nThis class template is used to specify a transition reaction. Instantiations of this template can appe ar in the \nreactions member typedef in models of the SimpleState and State concepts. \nClass template transition parameters \nClass template transition synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< \n class Event, \n class Destination, \n class TransitionContext = unspecified , \n void ( TransitionContext::*pTransitionAction )( \n const Event & ) = unspecified > \n class transition \n { \n // implementation-defined \n }; \n} \n} \nClass template transition semantics \nWhen executed, one of the following calls to a memb er function of the state for which the reaction was defined is Template \nparameter Requirements Semantics Default \nEvent A model of the Event concept or the class \nevent_base The event triggering the \ntransition. If \nevent_base is specified, \nthe transition is triggered \nby all models of the \nEvent concept \nDestination A model of the SimpleState or State concepts or \nan instantiation of the shallow_history or \ndeep_history class templates. The source state \n(the state for which this transition is defined) \nand Destination must have a common direct \nor indirect context The destination state to \nmake a transition to \nTransitionContext A common context of the source and \nDestination state The state of which the \ntransition action is a \nmember unspecified \npTransitionAction A pointer to a member function of \nTransitionContext . The member function \nmust accept a const Event & parameter and \nreturn void The transition action that \nis executed during the \ntransition. By default no \ntransition action is \nexecuted unspecified Page 31 of 35 The Boost Statechart Library - Reference \n2008/01/06made: \n/circle6transit< Destination >() , if no transition action was specified \n/circle6transit< Destination >( pTransitionAction, currentEvent ) , if a transition action \nwas specified \nHeader <boost/statechart/in_state_reaction.hpp> \nClass template in_state_reaction \nThis class template is used to specify an in-state reaction. Instantiations of this template can appea r in the \nreactions member typedef in models of the SimpleState and State concepts. \nClass template in_state_reaction parameters \nClass template in_state_reaction synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< \n class Event, \n class ReactionContext = unspecified , \n void ( ReactionContext::*pAction )( \n const Event & ) = unspecified > \n class in_state_reaction \n { \n // implementation-defined \n }; \n} \n} \nClass template in_state_reaction semantics \nWhen executed then the following happens: \n1. If an action was specified, pAction is called, passing the triggering event as the onl y argument \n2. A call is made to the discard_event member function of the state for which the reaction was defined Template \nparameter Requirements Semantics Default \nEvent A model of the Event concept or the \nclass event_base The event triggering the in-state \nreaction. If event_base is \nspecified, the in-state reaction is \ntriggered by all models of the \nEvent concept \nReactionContext Either the state defining the in-state \nreaction itself or one of it direct or \nindirect contexts The state of which the action is a \nmember unspecified \npAction A pointer to a member function of \nReactionContext . The member \nfunction must accept a const Event & \nparameter and return void The action that is executed during \nthe in-state reaction unspecified Page 32 of 35 The Boost Statechart Library - Reference \n2008/01/06Header <boost/statechart/ termination.hpp > \nClass template termination \nThis class template is used to specify a terminatio n reaction. Instantiations of this template can app ear in the \nreactions member typedef in models of the SimpleState and State concepts. \nClass template termination parameters \nClass template termination synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class Event > \n class termination \n { \n // implementation-defined \n }; \n} \n} \nClass template termination semantics \nWhen executed, a call is made to the terminate member function of the state for which the reactio n was \ndefined. \nHeader <boost/statechart/deferral.hpp> \nClass template deferral \nThis class template is used to specify a deferral r eaction. Instantiations of this template can appear in the \nreactions member typedef in models of the SimpleState and State concepts. \nClass template deferral parameters \nClass template deferral synopsis \nnamespace boost \n{ \nnamespace statechart Template \nparameter Requirements Semantics \nEvent A model of the Event concept \nor the class event_base The event triggering the termination. If event_base is \nspecified, the termination is triggered by all mode ls of the \nEvent concept \nTemplate \nparameter Requirements Semantics \nEvent A model of the Event concept or \nthe class event_base The event triggering the deferral. If event_base is specified, \nthe deferral is triggered by all models of the Event concept Page 33 of 35 The Boost Statechart Library - Reference \n2008/01/06{ \n template< class Event > \n class deferral \n { \n // implementation-defined \n }; \n} \n} \nClass template deferral semantics \nWhen executed, a call is made to the defer_event member function of the state for which the reactio n was \ndefined. \nHeader <boost/statechart/custom_reaction.hpp> \nClass template custom_reaction \nThis class template is used to specify a custom rea ction. Instantiations of this template can appear i n the \nreactions member typedef in models of the SimpleState and State concepts. \nClass template custom_reaction parameters \nClass template custom_reaction synopsis \nnamespace boost \n{ \nnamespace statechart \n{ \n template< class Event > \n class custom_reaction \n { \n // implementation-defined \n }; \n} \n} \nClass template custom_reaction semantics \nWhen executed, a call is made to the user-supplied react member function of the state for which the reactio n was \ndefined. The react member function must have the following signature: \nresult react( const Event & ); \nand must call exactly one of the following reaction functions and return the obtained result object: \nresult discard_event (); \nresult forward_event (); \nresult defer_event (); \ntemplate< class DestinationState > Template \nparameter Requirements Semantics \nEvent A model of the Event concept \nor the class event_base The event triggering the custom reaction. If event_base is \nspecified, the custom reaction is triggered by all models of the \nEvent concept Page 34 of 35 The Boost Statechart Library - Reference \n2008/01/06result transit (); \ntemplate< \n class DestinationState, \n class TransitionContext, \n class Event > \nresult transit ( \n void ( TransitionContext::* )( const Event & ), \n const Event & ); \nresult terminate (); \nHeader <boost/statechart/result.hpp> \nClass result \nDefines the nature of the reaction taken in a user- supplied react member function (called when a \ncustom_reaction is executed). Objects of this type are always obta ined by calling one of the reaction \nfunctions and must be returned from the react member function immediately. \nnamespace boost \n{ \nnamespace statechart \n{ \n class result \n { \n public: \n result ( const result & other ); \n ~result (); \n \n private: \n // Result objects are not assignable \n result & operator=( const result & other ); \n }; \n} \n} \nClass result constructor and destructor \nresult( const result & other ); \nRequires : other is not consumed \nEffects : Copy-constructs a new result object and marks other as consumed. That is, result has destructive \ncopy semantics \n~result(); \nRequires : this is marked as consumed \nEffects : Destructs the result object \n \nRevised 06 January, 2008 \nCopyright © 2003-2008 Andreas Huber Dönni \nDistributed under the Boost Software License, Versi on 1.0. (See accompanying file LICENSE_1_0.txt or copy at \nhttp://www.boost.org/LICENSE_1_0.txt ) \nPage 35 of 35 The Boost Statechart Library - Reference \n2008/01/06" } ]
{ "category": "App Definition and Development", "file_name": "reference.pdf", "project_name": "ArangoDB", "subcategory": "Database" }