Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-03

To thread or not to thread

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Christophe Espern

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

Reply by email

Christophe Espern
to Christophe Espern

Le lun 03/03/2003 à 23:11, Christophe Espern a écrit : Hello,

After a short night :

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

I confirm : nanosleep works well. The task has a problem.

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

Here is the problem.

First I must call g_thread_init to use threads in GTK but I cannot link the program o.file with the script provided with gtk2forpascal. pgk-config does not mention the glib thread library.

Maybe I must recompile GTK with threading support.

Anyone has already used GTK threads with FPC and gtk2forpascal ?

Cheers,

Christophe

Reply by email