Bartek Walter wrote:
> 
> jb> This is part of source code of BaseXXX
> 
> jb> ...
> jb>     public void save(DBConnection dbCon) throws Exception
> jb>     {
> jb>         if (!alreadyInSave)
> jb>       {
> jb>         alreadyInSave = true;
> jb>           if (isModified())
> jb>         {
> jb>             if (isNew())
> jb>             {
> jb>                 XXXPeer.doInsert((XXX)this, dbCon);
> jb>                 setNew(false);
> jb>             }
> jb>             else
> jb>             {
> jb>                 XXXPeer.doUpdate((XXX)this, dbCon);
> jb>             }
> jb>         }
> jb>               alreadyInSave = false; // Why this line? It's just saved, right?
> jb>       }
> jb>    }
> jb> ...
> 
> it is a kind of a semaphore, I think, in order to avoid race
> conditions when saving the same object concurrently.
> This method is not synchronized probably for efficiency purposes, so
> the semaphore does the job.

Torque objects are not thread safe.  They are meant to be instantiated
and used by one thread at time.  The code in question is meant to help
with the condition where object A contains object B's at least one of
which contains a reference back to A.  In such a case a.save() could
cause an infinite loop.

john mcnally

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to