utwente-fmt / sylvan

Multi-core Decision Diagram (BDD/LDD) implementation
Apache License 2.0
41 stars 8 forks source link

Reason protect preferred over addref ? #9

Closed thisiscam closed 7 years ago

thisiscam commented 8 years ago

I'm working on a C# binding of sylvan here https://github.com/thisiscam/SylvanSharp

I'm wondering why is "protect/unprotect" preferred over "ref/deref"? I don't want to make very subtle bugs(especially in a concurrent C# program) so a hint of explanation will be really helpful!

trolando commented 8 years ago

protect/unprotect is simply more versatile, as it requires less calls to protect/unprotect than to ref/deref.

Maybe over the lifetime of a variable you change its values hundreds of times. Those are hundreds of ref/deref calls you don't have to do if you use protect/unprotect.