Re: why boost:shared_ptr so slower?
"Chris M. Thomasson" <no@spam.invalid> wrote in message
news:h6m7gt$2f6k$1@news.ett.com.ua...
"Juha Nieminen" <nospam@thanks.invalid> wrote in message
news:%Djjm.223$1Y6.48@read4.inet.fi...
Keith H Duggar wrote:
Boost shared_ptr is not "thread safe" by any standard that is
usually meant by the term:
http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm#ThreadSafety
First you claim that it's not thread-safe, and then you point to the
documentation which says that it is.
ie "the same level of thread safety as built-in types" means
not "thread safe".
You are confusing two different types of thread-safety.
[...]
FWIW, Boost shared_ptr only provides basic/normal thread-safety. It does
NOT provide strong thread-safety in any way shape or form. Read the entire
following thread:
http://groups.google.com/group/comp.programming.threads/browse_frm/thread/e5167941d32340c6/1b2e1c98fa9ad7c7
You simply cannot use shared_ptr in a scenario which demands strong thread
safety level. For example, this will NOT work:
_______________________________________________________________
static shared_ptr<foo> global_foo;
void writer_threads() {
for (;;) {
shared_ptr<foo> local_foo(new foo);
global_foo = local_foo;
}
}
void reader_threads() {
for (;;) {
shared_ptr<foo> local_foo(global_foo);
local_foo->read_only_operation()();
}
}
_______________________________________________________________
[...]
Here is a pre-alpha implementation of my experimental strongly thread-safe
reference counting algorithm:
http://webpages.charter.net/appcore/vzoom/refcount
Here is some very crude documentation of the C API:
http://webpages.charter.net/appcore/vzoom/refcount/doc
I proposed this algorithm for Boost a while ago, but I never really followed
up on it and did not make a formal proposal. Here are the relevant posts:
http://search.gmane.org/?query=&group=gmane.comp.lib.boost.devel&author=chris%20thomasson
Here is a fairly detailed description of exactly how the "strong
thread-safety aspect" of the algorithm works:
http://article.gmane.org/gmane.comp.lib.boost.devel/149803
Enjoy!