[statechart] Using fast_pool_allocator along with state_machine

Hi, I would like to avoid fragmentation and perhaps reduce the time spent entering and leaving state in my state machine by leveraging the fast_pool_allocator. My very limited understanding of allocators comes from Scott Meyer's Effective STL and his references to articles on the Web. From reading the implementation of state_machine, I am not clear what the template-arguments for the UserAllocator should be if I wish to use the fast_pool_allocator as the UserAllocator parameter for state-machine. If I specified boost::fast_pool_allocator<int> does the library take care of somehow doing a rebind and allocating the right amount of memory for the states ?
From reading the changeset documentation (Point 2, Breaking Change of 14 August 2005) I see that
" this considerably simplifies memory management customization. A user now only needs to pass his own allocator to state_machine<> and no longer has to separately overload operator
new/delete for his state classes"
Any guidance would be really appreciated ?
Thanks
#ifndef __STATE_H_INCL__
#define __STATE_H_INCL__
#include

Hi
If I specified boost::fast_pool_allocator<int> does the library take care of somehow doing a rebind and allocating the right amount of memory for the states ?
Yes, please see: http://www.boost.org/doc/libs/1_35_0/libs/statechart/doc/faq.html#HardRealti... http://www.boost.org/doc/libs/1_35_0/libs/statechart/doc/reference.html#Clas..., Allocator parameter http://www.boost.org/doc/libs/1_35_0/libs/statechart/doc/reference.html#Clas..., Allocator parameter [snip]
struct Enabled; struct Machine : sc::state_machine< Machine, Enabled, boost::fast_pool_allocator< int > > /* ??? is this right ? */ { Machine(); ~Machine() { terminate(); } int ContextAssociatedwithStateMachine; };
Looks good to me. boost::fast_pool_allocator< int > is used in the performance example here: http://www.boost.org/doc/libs/1_35_0/libs/statechart/example/Performance/Per... HTH & Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Babi Seal