Hallo all,
I had tried to adopt the delphi code to Lazarus and got follow missunderstood.
unit u_amqp_threads;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
AMQP.Connection, AMQP.Interfaces, AMQP.Classes
;
type
TProducerThread = Class(TThread)
Strict Private
FAMQP: TAMQPConnection;
FMaxWork: Integer;
FSleepMS: Integer;
Procedure WriteLine( Text: String );
Protected
Procedure Execute; Override;
constructor CreateP( AAMQP: TAMQPConnection; AMaxWork, ASleepMS: Integer );
End;
T_ConsumerThread = Class(TThread)
Strict Private
FAMQP: TAMQPConnection;
FChannel: IAMQPChannel;
FList: TStringList;
Procedure WriteLine( Text: String );
Protected
Procedure TerminatedSet; Override;
Procedure Execute; Override;
constructor Create( AAMQP: TAMQPConnection; const aList: TStringList );
End;
....
[code=pascal]unit u_custapp;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, custapp,
AMQP.Connection, AMQP.Interfaces, AMQP.Classes
, u_amqp_threads
;
type
{ TAMQPApplication }
TAMQPApplication = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
class var AMQPApplication : TAMQPApplication;
class procedure AppStart;
public
mc1, mc2 : TStringList;
AMQP: TAMQPConnection;
Producer: TProducerThread;
Consumer1: T_ConsumerThread;
Consumer2: T_ConsumerThread;
end;
implementation
procedure TAMQPApplication.DoRun;
var
ErrorMsg: String;
begin
mc1 := TStringList.create;
mc2 := TStringList.create;
Consumer1 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc1 );
Consumer2 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc2 );
Producer := u_amqp_threads.TProducerThread.Create( AMQP, 2, 10 );
.....
[/code]
Consumer1 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc1 );
u_custapp.pas(41,68) Error: Incompatible type for arg no. 2: Got "TStringList", expected "QWord"
classes.inc(225,21) Hint: Found declaration: constructor Create(Boolean;const QWord=`4194304`);
Consumer2 := u_amqp_threads.T_ConsumerThread.Create( AMQP, mc2 );
u_custapp.pas(42,68) Error: Incompatible type for arg no. 2: Got "TStringList", expected "QWord"
classes.inc(225,21) Hint: Found declaration: constructor Create(Boolean;const QWord=`4194304`);
Producer := u_amqp_threads.TProducerThread.Create( AMQP, 2, 10 );
u_custapp.pas(43,69) Error: Wrong number of parameters specified for call to "Create"
Z:\fpcdelux\fpcsrc\rtl\objpas\classes\classes.inc
It looks, that a compiler try to build the constructor from parent-class(TThread). Tjhe options like 'reintroduce' and 'overload' did not help. What is wrong in the code and how I can fix it?