System.Threading.TTask.Future

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class function Future<T>(Sender: TObject; Event: TFunctionEvent<T>): IFuture<T>; overload; static; inline;
class function Future<T>(Sender: TObject; Event: TFunctionEvent<T>; APool: TThreadPool): IFuture<T>; overload; static; inline;
class function Future<T>(const Func: TFunc<T>): IFuture<T>; overload; static; inline;
class function Future<T>(const Func: TFunc<T>; APool: TThreadPool): IFuture<T>; overload; static; inline;

C++

inline System::DelphiInterface<IFuture__1<T> > __fastcall TTask::Future(
    System::TObject* Sender,
    T __fastcall (__closure *Event)(System::TObject* Sender))
inline System::DelphiInterface<IFuture__1<T> > __fastcall TTask::Future(
    System::TObject* Sender,
    T __fastcall (__closure *Event)(System::TObject* Sender),
    TThreadPool* APool)
inline System::DelphiInterface<IFuture__1<T> > __fastcall TTask::Future(
    const System::DelphiInterface<System::Sysutils::TFunc__1<T> > Func)
inline System::DelphiInterface<IFuture__1<T> > __fastcall TTask::Future(
    const System::DelphiInterface<System::Sysutils::TFunc__1<T> > Func,
    TThreadPool* APool)

Properties

Type Visibility Source Unit Parent
function public
System.Threading.pas
SystemThreading.h
System.Threading TTask

Description

Future accepts a function able to run in a parallel thread, returning an interface used to get the result at the point in the program that is needed.

The return value of the function is obtained at the point needed in the program through the instance of IFuture<T> given by the result of Future<T>. The type parameter, T, represents the return type of the function given to run in a parallel thread.

The Future method returns an instance of IFuture into the variable defined of type T.

Call the first overloaded Future method with the parameters described below.

Parameter Meaning
Sender An object containing data to be used by the Event.
Event A function that returns the instance of the value T and is given the Sender object as a parameter.

Call the second overloaded Future method with the parameters described below.

Parameter Meaning
Sender An object containing data to be used by the Event.
Event A function that returns the instance of the value T and is given the Sender object as a parameter.
APool A thread-pool used to execute the function.


Call the third overloaded Future method with the parameters described below.

Parameter Meaning
Func A TFunc reference to the function that returns the instance of the value T.

Call the fourth overloaded Future method with the parameters described below.

Parameter Meaning
Func A TFunc reference to a function that returns the instance of the value T.
APool A thread-pool used to execute the function.

When present, Sender parameters are passed along to the target function like what happens with event handlers, offering the properties and methods of the Sender object to the function targeted to run in a parallel thread.

Whether or not a function is able to run in a parallel thread depends upon the CPU and available threading resources of the target platform at the time execution. When a ThreadPool parameter is specified, threading resources for the call to Future<T> will be drawn from here instead of from a default pool; used when threading resources might need to be limited, allowing threading resources to be available for other purposes.

See Also