c++ - Can boost::lockfree::stack accept string pointers safely? -
i've discovered passing string
pointer boost::lockfree::queue
cause memory leak because string
pointer cannot released.
is situation same boost::lockfree::stack
?
the requirement boost::lockfree::stack
is:
- t must have copy constructor
if regular string
pointer cannot used, there other way string
can put boost::lockfree::stack
?
regular string
when try this
boost::lockfree::stack<string> my_stack(128);
i these errors
boost_static_assert(boost::has_trivial_assign<t>::value); boost_static_assert(boost::has_trivial_destructor<t>::value);
which seems strange me, because of inexperience, because requirements boost::lockfree::queue
strangely has no documentation
- t must have copy constructor
- t must have trivial assignment operator
- t must have trivial destructor
the missing documentation doxygen bug, documentation page gets name macro :(, , here: http://www.boost.org/doc/libs/1_55_0/doc/html/boost/lockfree/boost_no_cxx1_idp100289128.html
indeed stack appears have same element type requirements queue, despite fact documentation doesn't mention it. what's worse, seems
boost::string_ref
hasn't been kept pod either.
so suggestion store pointers "pool" of immutable string objects , free pool @ time when queue freed. way, have manage lifetime of queue in such way memory consumption doesn't grow out of control.
in ways resembles implementing poor-man's gc, , yes, will force regular delays in throughput re-initialize queue; in fairness common field of lock-less memory management, , boost lockfree documentation states, "viable" memory reclamation schemes in existence patented.
you might have @ libcds: lock-free concurrent datastructures in case want toy of these algorithms. think author of library has been in active conversation boost developers proposing libcds
boost, , did not take place because of patent issues.
Comments
Post a Comment