[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #18362 [Tor]: Tor could use a generic 'handle' / 'weakref' implementation.



#18362: Tor could use a generic 'handle' / 'weakref' implementation.
-------------------------+------------------------------------
 Reporter:  nickm        |          Owner:  nickm
     Type:  enhancement  |         Status:  accepted
 Priority:  High         |      Milestone:  Tor: 0.2.9.x-final
Component:  Tor          |        Version:
 Severity:  Normal       |     Resolution:
 Keywords:  modularity   |  Actual Points:
Parent ID:               |         Points:  small
  Sponsor:  SponsorS     |
-------------------------+------------------------------------

Comment (by cypherpunks):

 Replying to [ticket:18362 nickm]:

 >  the third is slower than regular pointer access.

 If you have a thread safe implementation, that's not really the case. You
 are going to use several atomic operations for each access, so a hashtable
 access wouldn't add that much overhead (probably comparable to 1 atomic
 operation using an int/int64 key).

 Your weakref implementation looks fundamentally broken. You need to
 convert the weak reference to a strong one before using the pointed to
 object. Otherwise, the object can get deleted in a multi-threaded context.
 You may want to look at C++ shared_ptr/weak_ptr.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/18362#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs