<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3354" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2> Hmm... it looks almost one to one copy from
our code in Version 4.0 of our libraries ;-) . Are you one of our customers, or
you have simply come with the same idea as us?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> With best regards,<BR> Boian Mitov</DIV>
<DIV> </DIV>
<DIV>--------------------------------------------------------------------<BR>Mitov
Software<BR><A
href="http://www.mitov.com">http://www.mitov.com</A><BR>--------------------------------------------------------------------</DIV>
<DIV> </DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=hgourvest@progdigy.com href="mailto:hgourvest@progdigy.com">Henri
Gourvest</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">FPC developers' list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, July 31, 2008 5:57
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [fpc-devel] Re: Multi
threading support</DIV>
<DIV><BR></DIV>
<DIV dir=ltr>This is an idea using automatic cleanup of
interfaces:<BR><BR>procedure foo; <- lock<BR>begin<BR>
synchronize(cs);<BR> [...]<BR>end; <-
unlock<BR><BR>or<BR><BR>procedure foo; <- lock<BR>begin<BR>
with synchronize(cs) do <- lock<BR> begin<BR>
[...]<BR> end; <- unlock<BR>end;<BR><BR><BR>{
TLock }<BR><BR>type<BR> TLock = class(TInterfacedObject)<BR>
private<BR> FCriticalSection: TCriticalSection;<BR>
public<BR> constructor Create(cs: TCriticalSection);
virtual;<BR> destructor Destroy; override;<BR>
end;<BR><BR>constructor TLock.Create(cs: TCriticalSection);<BR>begin<BR>
FCriticalSection := cs;<BR> cs.Acquire;<BR>end;<BR><BR>destructor
TLock.Destroy;<BR>begin<BR> FCriticalSection.Release;<BR>
inherited;<BR>end;<BR><BR>function synchronize(cs: TCriticalSection):
IUnknown;<BR>begin<BR> Result :=
TLock.Create(cs);<BR>end;<BR><BR><BR><BR><BR><BR><BR>
<DIV class=gmail_quote>2008/7/31 tom_at_work <SPAN dir=ltr><<A
href="mailto:tom_at_work@gmx.at">tom_at_work@gmx.at</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hello,<BR><BR>Am
31.07.2008 um 11:56 schrieb Florian Klaempfl:<BR><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Vinzent
Höfler schrieb:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">--------
Original-Nachricht -------
<DIV class=Ih2E3d><BR>OTOH, it's looks about the same as in Java and
even Java now has<BR>explicit Locks, because "synchronized" simply isn't
efficient nor<BR>flexible enough... ;)<BR></DIV></BLOCKQUOTE><BR>Since I
don't use java, what's the difference to locks?<BR><BR></BLOCKQUOTE><BR>In
practice imo not too much, synchronized is just a convenience functionality,
exactly like the one you proposed.<BR><BR>In short the
difference:<BR><BR>Java always locks on monitors i.e. guards which are
available for any object; Pre 1.5 the only way to lock was using some syntax
additions. The syntax allows per method (class or instance) or per block
scope, i.e.<BR><BR>synchronized void doSomething() { ... } // method level:
monitor object is either "this" or this.class object<BR><BR>void
doSomething() {<BR> ...<BR> synchronized (monitor) { // on block
level; monitor object is "this" if not specified otherwise the given
object<BR> }<BR> ...<BR>}<BR><BR>With 1.5 they added a "Lock"
interface which provides the usual lock()/trylock()/unlock() methods which
should be self-explaining.<BR>This for example allows interlocked locks if
required<BR><BR>lock1.lock();<BR>...<BR>lock2.lock();<BR>...<BR>lock1.unlock();<BR>...<BR>lock2.unlock();<BR><BR><BR>Hth,<BR> Thomas_______________________________________________
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><BR>fpc-devel maillist - <A
href="mailto:fpc-devel@lists.freepascal.org"
target=_blank>fpc-devel@lists.freepascal.org</A><BR><A
href="http://lists.freepascal.org/mailman/listinfo/fpc-devel"
target=_blank>http://lists.freepascal.org/mailman/listinfo/fpc-devel</A><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR></BLOCKQUOTE></BODY></HTML>