You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
引用计数在并发环境下,由于需要考虑并发问题,通常会引入原子操作,降低了引用计数的性能。
一种思路:
假定我们的编程语言的并发范式是 actor。
那么我们在讲一个可回收对象 send 到别的 actor 中去的时候,可以在那个 actor 下对这个对象单独进行计数。而原来的 actor 里的计数给它加一。当另外那个 actor 里的计数等于 0 的时候,才跨线程去更新原来 actor 里的计数减一,这样极大的减少了并发操作的次数,并且也不需要在计数上搞原子操作了。利用 actor 的消息队列就行了。
Activity