Mark, this was not exactly my point, to prevent copy via private copy
constructor.
Some people believe automatic reference counter is slow because in C++
programmer does not have a control of how and when an object is copied.
Thus even passing some smart_ptr<something> will increment its usage counter
and, because we use atomic increment for that, it will be slow.
My point was that parameter can be passed by reference & , so no copy/atomic
increment will occur. And that C++ programmer has the control of what is
being copied and what not.
> -----Original Message-----
> From: falcon-return-17-wlad=sun.com@stripped [mailto:falcon-
> return-17-wlad=sun.com@stripped] On Behalf Of MARK CALLAGHAN
> Sent: Monday, October 06, 2008 9:01 PM
> To: Vladislav Vaintroub
> Cc: Kevin.Lewis@stripped; falcon@stripped
> Subject: Re: Understanding RefCounts in Falcon
>
> On Mon, Oct 6, 2008 at 11:12 AM, Vladislav Vaintroub <wlad@stripped>
> wrote:
> >> The advantage of targeted reference counting is performance.
> >> The advantage of smart pointers is stability.
> >
> > I'm about to give up. All discussions during Boston meeting are in
> vain.
> > References are non-existent feature of C++ and it is not possible to
> prevent
> > copying and object when it is passed as function parameter. Therefore
> smart
> > pointers are slow.
>
> I am not sure if this is what you want to do, but you can prevent
> objects from being copied. Mutex_sentry from sql/log.cc does just
> that.
>
> class Mutex_sentry {
> public:
> Mutex_sentry(pthread_mutex_t *mutex) : m_mutex(mutex) {
> if (m_mutex) pthread_mutex_lock(mutex);
> }
>
> ~Mutex_sentry() {
> if (m_mutex) pthread_mutex_unlock(m_mutex);
> #ifndef DBUG_OFF
> m_mutex= 0;
> #endif
> }
>
> private:
> pthread_mutex_t *m_mutex;
>
> // It's not allowed to copy this object in any way
> Mutex_sentry(Mutex_sentry const&);
> void operator=(Mutex_sentry const&);
> };
>
> >
> >> From: Kevin.Lewis@stripped [mailto:Kevin.Lewis@stripped]
> >> Sent: Monday, October 06, 2008 7:07 PM
> >> To: falcon@stripped
> >> Subject: Understanding RefCounts in Falcon
> >
> >
> >
> > --
> > Falcon Storage Engine Mailing List
> > For list archives: http://lists.mysql.com/falcon
> > To unsubscribe:
> http://lists.mysql.com/falcon?unsub=1
> >
> >
>
>
>
> --
> Mark Callaghan
> mdcallag@stripped
>
> --
> Falcon Storage Engine Mailing List
> For list archives: http://lists.mysql.com/falcon
> To unsubscribe: http://lists.mysql.com/falcon?unsub=1