[shifted_ptr] Updated thread and <const T> support

Greetings: Upon testing the library on day to day projects, support for <const T> objects is invaluable and thus was added. Support for volatile objects could be important in certain cases also but requires more overloaded functions to be added (const ^2 + volatile ^2). Furthermore I have changed the code to use the new thread_specific_ptr<> object handler but I have disabled it by default with BOOST_SH_DISABLE_THREADS. Thanks, -Phil

"Phil Bouchard" <philippe@fornux.com> wrote in message news:fttv4j$4t6$1@ger.gmane.org...
Greetings:
Upon testing the library on day to day projects, support for <const T> objects is invaluable and thus was added. Support for volatile objects could be important in certain cases also but requires more overloaded functions to be added (const ^2 + volatile ^2).
[...] It turns out volatile seems to be working fine now. I discard qualifiers during some casts inside rootof() and roofof() but they get reenabled in the final convertions. There is no need for overloads this way. -Phil

AMDG Phil Bouchard wrote:
Greetings:
Upon testing the library on day to day projects, support for <const T> objects is invaluable and thus was added. Support for volatile objects could be important in certain cases also but requires more overloaded functions to be added (const ^2 + volatile ^2).
Furthermore I have changed the code to use the new thread_specific_ptr<> object handler but I have disabled it by default with BOOST_SH_DISABLE_THREADS.
I just tried it out on msvc 9.0. It breaks on sh_owned_base_nt.hpp line 107 because of the windows min/max macros In Christ, Steven Watanabe

"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:480399C5.60009@providere-consulting.com...
I just tried it out on msvc 9.0.
It breaks on sh_owned_base_nt.hpp line 107 because of the windows min/max macros
Thanks I just added some undefs since I haven't seen the necessity of pushing / popping them. -Phil

AMDG Phil Bouchard wrote:
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:480399C5.60009@providere-consulting.com...
I just tried it out on msvc 9.0.
It breaks on sh_owned_base_nt.hpp line 107 because of the windows min/max macros
Thanks I just added some undefs since I haven't seen the necessity of pushing / popping them.
You should probably use (std::numeric_limits<>::min)() which disables macro expansion. Otherwise, the inspection program will complain. In Christ, Steven Watanabe

AMDG Phil Bouchard wrote:
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48051355.3010309@providere-consulting.com...
You should probably use (std::numeric_limits<>::min)() which disables macro expansion. Otherwise, the inspection program will complain.
Res gestae.
Ok. Now it compiles. Some comments on the documentation. "Memory usage having a power of 2 (sizeof(void *) * 2)" What does this mean? The use of the term "cubic" always catches me because I automatically associate it with O(n^3) which is not what you mean. It would also be nice to know what kinds of cycles it doesn't handle. Finally, here are the warnings from msvc 9.0 /w4 Warning 1 warning C4355: 'this' : used in base member initializer list c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\detail\intrusive_list.hpp 39 Warning 2 warning C4355: 'this' : used in base member initializer list c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\detail\intrusive_list.hpp 39 Warning 3 warning C4100: 'ti' : unreferenced formal parameter c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\detail\sh_owned_base_nt.hpp 206 Warning 4 warning C4099: 'boost::detail::sh::owned_base' : type name first seen using 'class' now seen using 'struct' c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\shifted_ptr.hpp 42 Warning 5 warning C4355: 'this' : used in base member initializer list c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\shifted_ptr.hpp 61 Warning 6 warning C4100: 'other' : unreferenced formal parameter c:\documents and settings\steven\my documents\visual studio 2008\projects\shifted_ptr\shifted_ptr\shifted_ptr.cpp 38 Warning 7 warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data c:\documents and settings\steven\my documents\boost\boost\date_time\microsec_time_clock.hpp 179 Warning 8 warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data c:\documents and settings\steven\my documents\boost\boost\date_time\microsec_time_clock.hpp 179 Warning 9 warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data c:\documents and settings\steven\my documents\boost\boost\date_time\microsec_time_clock.hpp 179 Warning 10 warning C4100: 'ti' : unreferenced formal parameter c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\detail\sh_owned_base_nt.hpp 136 Warning 11 warning C4100: 'ti' : unreferenced formal parameter c:\documents and settings\steven\my documents\vendor\boost\shifted_ptr\shifted_ptr\boost\detail\sh_owned_base_nt.hpp 136 Warning 12 warning C4512: 'boost::algorithm::detail::find_format_store<ForwardIteratorT,FormatterT,FormatResultT>' : assignment operator could not be generated c:\documents and settings\steven\my documents\boost\boost\algorithm\string\detail\find_format_store.hpp 65 You may just have to #pragma warning push/pop disable 4355 In Christ, Steven Watanabe

"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48061126.40705@providere-consulting.com... [...]
It would also be nice to know what kinds of cycles it doesn't handle.
[...] Sorry for the quick email... I have to go but it clears everything up the heap, there is no possible cyclicism. -Phil

AMDG Phil Bouchard wrote:
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48061126.40705@providere-consulting.com...
[...]
It would also be nice to know what kinds of cycles it doesn't handle.
[...]
Sorry for the quick email... I have to go but it clears everything up the heap, there is no possible cyclicism.
really? #include <boost/shifted_ptr.hpp> #include <vector> #include <iostream> static int count; struct X { X() { ++count; } ~X() { --count; } X(const X& other) : vec(other.vec) { ++count; } std::vector<boost::shifted_ptr<X> > vec; }; int main() { { boost::shifted_ptr<X> x = boost::new_sh<X>(); x->vec.push_back(x); } std::cout << count << std::endl; } In Christ, Steven Watanabe

"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48063795.5050100@providere-consulting.com... [...]
Sorry for the quick email... I have to go but it clears everything up the heap, there is no possible cyclicism.
really?
#include <boost/shifted_ptr.hpp>
#include <vector> #include <iostream>
static int count;
struct X { X() { ++count; } ~X() { --count; } X(const X& other) : vec(other.vec) { ++count; } std::vector<boost::shifted_ptr<X> > vec; };
int main() { { boost::shifted_ptr<X> x = boost::new_sh<X>(); x->vec.push_back(x); } std::cout << count << std::endl; }
Ok that's a good point. My routines delimits the heap segment using an overriden owned<>::operator new. If this operator new isn't used then shifted_ptr will think the object resides on the stack or data frames; vector<> uses the global operator new. I'll figure out something else. I have discovered also another bug related to the set counter. Now Vault contains the corrected version. Regards, -Phil

AMDG Phil Bouchard wrote:
I have discovered also another bug related to the set counter. Now Vault contains the corrected version.
Ok. Another issue. Is it possible to deal with this: The nodes will never be cleaned up until the list is destroyed. Or that's what I thought.... The nodes don't seem to be cleaned up at all. #include <boost/shifted_ptr.hpp> #include <vector> #include <iostream> static int count; using boost::shifted_ptr; using boost::new_sh; struct node { node() { ++count; } ~node() { --count; } node(const node&) { ++count; } shifted_ptr<node> prior; shifted_ptr<node> next; }; struct list { public: list() {} void clear() { front.reset(); back.reset(); } void insert() { if(front.get() == 0) { front = back = new_sh<node>(); } else { back->next = new_sh<node>(); back->next->prior = back; back = back->next; } } private: shifted_ptr<node> front; shifted_ptr<node> back; }; int main() { list l; for(int j = 0; j < 10; ++j) { for(int i = 0; i < 100; ++i) { l.insert(); } l.clear(); } std::cout << count << std::endl; } In Christ, Steven Watanabe

"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:4807988D.7020207@providere-consulting.com...
Ok. Another issue. Is it possible to deal with this: The nodes will never be cleaned up until the list is destroyed. Or that's what I thought.... The nodes don't seem to be cleaned up at all.
[...] This is an implementation bug; I am investigating. Moreover, there is a symbol called heap_start under Linux which tells about the heap boundaries. This is great we'll be able to unify all allocations. -Phil

"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:48061126.40705@providere-consulting.com... [...]
"Memory usage having a power of 2 (sizeof(void *) * 2)" What does this mean?
sizeof(void *) + sizeof(void *) == sizeof(shifted_ptr<void>)
The use of the term "cubic" always catches me because I automatically associate it with O(n^3) which is not what you mean.
It's like a memory matrix of the 3rd order bringing 3 distinct ways of isolating unreferenced objects. [...]
You may just have to #pragma warning push/pop disable 4355
I just made the corrections. Vc 8 isn't reporting such warnings. -Phil

"Phil Bouchard" <philippe@fornux.com> wrote in message news:fu75as$lb$1@ger.gmane.org...
"Memory usage having a power of 2 (sizeof(void *) * 2)" What does this mean?
sizeof(void *) + sizeof(void *) == sizeof(shifted_ptr<void>)
Sorry I meant: sizeof(shifted_ptr<void> [256]) == sizeof(void *) * 512 I just wanted to point out it remains a multiple of 2 which is very convenient (not a power but multiple). -Phil
participants (2)
-
Phil Bouchard
-
Steven Watanabe