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. Besides, storing reference to object already 
increment its 
usage counter, so nobody can free the object during wrapper's life time.
   Besides, such copying inside of routine just don't work because another 
thread can 
nullify the pointer between entering into routine and copying.

> ITransaction is often passed as a parameter in functions of IAttachment
> / IStatement. Std way of resolving virtual interfaces does not work in
> this case. I.e. we have a risk that due to application bug wrong
> transaction (from other provider) is passed by user uncontrolled at
> compile time. Therefore getNextTransaction and getTransaction are needed.

   I see. TPC transactions, right. Statement must use for execution 
sub-transaction that 
belongs to its attachment.

>>      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 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().

-- 
   WBR, SD.

------------------------------------------------------------------------------
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

Reply via email to