[fpc-devel] POSIX threads and classes

Артем Смирнов smirnoffjr at gmail.com
Mon May 7 15:36:04 CEST 2007


I've got some troubles with pthread_cond_init when calling it in class
members. After this action next calling of class constructor for second
object bring to SIGSEGV. When I tried to use Object instead Class all seems
fine, but for my task Object not approach. What it can be?

program pthcondtest;

{$mode objfpc}{$H+}

uses
  pthreads;

type

TCondv =3D class
   CAttr : pthread_condattr_t;
   Cond : pthread_cond_t;
public
  constructor Create;
  destructor Destroy; override;
end;

{TCondv}
constructor TCondv.Create;
begin
  pthread_condattr_init(CAttr);
  pthread_cond_init(Cond, CAttr);
end;


destructor TCondv.Destroy;
begin
  inherited;
  pthread_cond_destroy(Cond);
  pthread_condattr_destroy(CAttr);
end;
{TCondv}

var
  obj1 : TCondv;
  obj2 : TCondv;
begin
  obj1 :=3D TCondv.Create;
  obj2 :=3D TCondv.Create;
  obj1.Destroy;
  obj2.Destroy;
end.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freepascal.org/lists/fpc-devel/attachments/20070507/71eb6=
a04/attachment.htm


More information about the fpc-devel mailing list