[fpc-pascal]To thread or not to thread

Christophe Espern cespern at free.fr
Mon Mar 3 23:11:01 CET 2003


Hello,

I'm playing with threads by using the TThread object under Linux with
FPC 1.06.

What is the equivalent to the sleep function found in Delphi ?

I tried nanosleep but the task assign to the thread seems to failed.

procedure  TVAProcess.Execute;
var tm:timespec;
begin
 while not Terminated do begin
  nanosleep(FInterval, tm);
  GeneSuiv;
 end;
end;

The task executed in the thread is the following (I'm using
gtk2forpascal.) :

gdk_threads_enter;
gdk_draw_line(Buffer,style^.black_gc,p1.x,p1.y,p2.x,p2.y);
gtk_widget_queue_draw_area (PGtkWidget(AsGObject),tl.x,tl.y,w+1, h+1);
gdk_threads_leave;



Nothing happens until I click or press a key. Then the app draws all the
point since the last user event received !!

As i saw an example in GTK doc using phtread, I'm also evaluating the
pthread wrapper for FPC wrote by Boyan Krastev :
http://code.masterbo.org/filez/pthreadfpc-0.1.tgz

Does someone use it ?

Cheers,

Christophe








More information about the fpc-pascal mailing list