I want to apply the IObjectPool from spring to my code in order to create a pool of objects (in my case, a thread class). Is there any example or documentation about the pools from spring?.
It's something like this:
TMyClass = class(TThread)
public
constructor Create;
procedure Execute; override;
end;
Another class:
uses
....
Spring.Container,
Spring.Container.Pool,
Spring.Container.Core,
Spring.Container.ComponentActivator,
Spring.Services,
....;
TOtherClass = class
private
FPool: IObjectPool;
FActivator: IComponentActivator;
....
end;
implementation
constructor TOtherClass.Create;
begin
FActivator := ServiceLocator.GetService<IComponentActivator>;
FPool := TSimpleObjectPool.Create(FActivator, 5 , 10);
FPool.Initialize(nil);
end;
procedure TOtherClass.AProcedure;
var
task: TMyTask;
begin
...
task := FPool.GetInstance(nil);
...
end;
I'm using XE6.
Regards.
Aucun commentaire:
Enregistrer un commentaire