-------- Original-Nachricht --------
> Von: Florian Klaempfl <[EMAIL PROTECTED]>
> 
> > OTOH, it's looks about the same as in Java and even Java now has
> > explicit Locks, because "synchronized" simply isn't efficient nor
> > flexible enough... ;)
> 
> Since I don't use java, what's the difference of locks?

More control over where, when and how parts of the code must be locked. So you 
can do finer grained, and thus usually more efficient, locking. Just like the 
classic approach. ;)

A good example might be the multiplereader-singlewriter locks. Doing that with 
synchronized can be really inefficient if a protected data structure gets 
written seldom, but read often.

That's BTW why I like the Ada approach of the protected object much more:

protected Buffer is
   entry Put (I : in Integer);  -- Potentially blocking (if internal queue is 
full)
   entry Get (I : out Integer);  -- Potentially blocking (if internal queue is 
empty)

   procedure Write_Something;  -- May write to the object, so can only be 
entered once, but never waits.
   function Read_Something;  -- Only reads, so this subroutine can be entered 
several times. Never waits.
end Buffer;

The basic idea is: entries may block (on guards = "condition variables"), 
procedures can only be entered once at a time, because they may change the 
object's state and functions can be entered concurrently. Of course, if a write 
operation currently occurs (procedure call), no read operation (function call) 
is allowed during that time. In that way, the whole data structure and 
operations on it are relatively well defined even in temporal terms.


Vinzent.
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to