<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="midPine.LNX.4.64.0611071041240.30240@gru.wisa.be"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">..., at least for the beginning !
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Why ? You don't need language enhancements for this IMHO. Scheduling and
messaging is OS territory, not programming language territory.
  </pre>
</blockquote>
e.g. Ada provides multithreading means as language elements and AFAIK,
other languages also provide "joins" for that. <br>
<br>
I do agree that right now this should be done without any language
enhancement, but in a platform independent way. <br>
<br>
Having this we will face two shortcomings:<br>
<br>
1) following the Delphi ways we have a message scheduler for the main
thread (GUI thread in Delphi) but not for the worker threads created by
TThread. This "asymmetrical" approach makes using threads a bit clumsy.
Once we provide a standard means to send messages to a thread we will
want to allow a worker thread react on a message like the main thread:
by firing an event and by using "Application.ProcessMessages" (so here
we would have a TThread.Application property). The TThread.Execute thus
would (optionally) be enabled to finish without ending the thread. This
enhancement can be done without enhancing the language at all.<br>
<br>
2) With that solution of (1) we would have a new thread model that now
follows the event driven programming paradigm like the main thread
does. With that we would want to integrate the thread programming more
tightly and more easy to use in the language. Here I would like to see
a means to create "thread events". With that I mean a way to create
"callback" properties for classes that not just provide a function call
but can be defined (either statically with the class implementation or
dynamically when fired) to run on a certain thread context. This would
of course mean sending a message with the parameters to the thread,
queuing it, and have the thread execute it once it's free to do so. The
"calling" thread should optionally be made waiting for the called
thread to do it's thing (like with "Synchronize", but more versatile as
parameters can be passed"). In that case a function result and "out"
parameters can be used. <br>
<br>
This is just an idea I had some time ago and not yet a fully grown
concept.<br>
<br>
<blockquote cite="midPine.LNX.4.64.0611071041240.30240@gru.wisa.be"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">I'm sure I'll do this (supposedly in January/February), unless somebody is
faster than that
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I seriously doubt someone will be faster, but one never knows. But I'm
looking forward to your contribution in this area :-)
  </pre>
</blockquote>
I already tried something like that several years ago, (see below).<br>
<blockquote cite="midPine.LNX.4.64.0611071041240.30240@gru.wisa.be"
 type="cite"><br>
  <pre wrap="">
TTimer is only available in Lazarus, not in FPC. It's hooked in the event
loop, I suppose.
  </pre>
</blockquote>
<br>
Ah ! At that time I did get it running in Lazarus and was struck, as it
did compile but not work without.<br>
<br>
That's really bad ! IMHO it should be possible to use TTimer and
TThread in a simple non-GUI way. (I maybe will need to do an embedded
project on an ARM/Linux system that does not have X or any widget
library.)<br>
What is the problem with that ? can we work together on making this
happen (e.g. extracting a part of the "Application" code from Lazarus,
but doing it's own event loop instead of using the OS for that.)<br>
I already tried (and contributed) some thing like that several years
ago (creating my own Application object and trying to provide most of
the Delphi thread primitives for Linux), but at that time all this was
bound to fail, as the memory
management was not thread save <span class="moz-smiley-s2"><span> :-( </span></span>.
(Lazarus was not started at that time AFAIK.)<br>
<br>
-Michael<br>
 <br>
<br>
</body>
</html>