Re: About rcgc_shared_ptr

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: About rcgc_shared_ptr

Boost - Dev mailing list

Hi,

I finally understand what is Top-Post. And feel very sorry for the Top-Posted emails, please pardon me.
My email writer is the default one with Win10, and it replies with Chinese RE, not English, and embedding Chinese characters.
Also sorry for the inconvenience when you’re reading the replies.

My aim is not to replace shared_ptr or weak_ptr, I’m trying to provide another choice.

Personally, I don’t like to decide when to use shared_ptr or weak_ptr and also don’t like the
IUnknown way of manually memory or object allocation management, just personally.

I like GC when I code in C# or Java for I don’t have to remember the trivial things beyond my design, BUT not its performance.

I code this in C++ because it would be too complicated if I insert code into JavaVM or C#’s native support platform.
As we have great flexibility coding whatever we want in C++ on the infrastructure level.

So this is what I’m going to do with this rcgc_shared_ptr: 1. use it in my projects, and make it go through tests to see
If its capable of doing things.2. Trying to make this a part of a GC based language or platform to see any performance
increasing. And if possible, just as I did in emails, contribute to communities and let other coders to decide if the work
Is helpful or even harmful.


Please forgive me to be such a rude guy for the first time to talk so much.

However, I do hope you can debug the code and hope this can be any help.

Best Regards,
Yilin


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: About rcgc_shared_ptr

Boost - Dev mailing list
A downgrade implementation can be like this
(which is actually my former implementation during the experiments)

We define an interface:

struct IDIsposable
{
  virtual void Dispose() = 0;
};
And implement this interface with class A

class A : public IDisposable
{
Public;
  A():disposed(false){}

public:
  virtual void Dispose(){
     if(!this->disposed){
        this->_pb.Dispose();//this Dispose belongs to rcgc_shared_ptr
        this->_pc.Dispose(); //this Dispose belongs to rcgc_shared_ptr
        this->disposed = true;
    }
  }
 bool disposed;
  rcgc_shared_ptr<B> _pb;
  rcgc_shared_ptr<C> _pc;

};

And we don’t care about ~A() and let the rcgc_shared_ptr call Dispose method of the IDisposable.
This would avoid the dtors definition.

However, this is not as elegant as the previous given solution in C++,
having to write more code which we don’t like to do,
although no difference in other languages or platforms.


I’m sorry that I have to call it a day now and have to get some sleep (4:06am here)
Waiting for your kindly response and suggestions.

Best Regards,
Yilin

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost