On 03/17/14 15:01, Dimitry Sibiryakov wrote: > 17.03.2014 8:47, Alex Peshkoff wrote: >> On 03/16/14 18:36, Dimitry Sibiryakov wrote: >>> Can someone explain me why Y-classes use strange tricks with >>> YEntry.next() instead of >>> direct calls to real interfaces returned by chosen provider? >> Copying next pointer to local (on stack) reference pointer helps to >> avoid risk of destroying an object from another thread and nullifying a >> pointer during operation. > There is no such risk from the beginning because y-valve is single > threaded as every > call is protected with mutex.
May be old API :) > Besides, storing reference to object already increment its > usage counter, so nobody can free the object during wrapper's life time. But using something like commit for transaction can nullify next pointer. > Besides, such copying inside of routine just don't work because another > thread can > nullify the pointer between entering into routine and copying. Yes. Therefore pointer to next object is first copied to local reference pointer and analyzed only after it. >>> Code contain no comments. Is it really hard when you make a decision >>> to describe why >>> you choose this way, what alternatives you considered and why they wouldn't >>> work in your >>> opinion?.. >> I always write comments in a places that appear not trivial to me - see >> getTransaction above. > Not all people has the same IQ and knowledge. I don't see any comment > about meaning of > the word "next" in method names next means next level's interface pointer what needs more comments here? > and explanation why YStatement cannot just have private > member "RefPtr<IStatement> NextStatement" (or better "RealStatement") and > call its methods > directly instead of using strange entry.next(). > I can't explain here any more in plain english - it's already much better described in c++ ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel