E-MailRelay
Public Member Functions | Friends | List of all members
GNet::Task Class Reference

A class for running an exectuable in a separate process with an asychronous completion callback. More...

#include <gtask.h>

Public Member Functions

 Task (TaskCallback &, ExceptionHandler &eh, const std::string &exec_error_format=std::string(), const G::Identity &=G::Identity::invalid())
 Constructor for a start()able object. More...
 
 ~Task ()
 Destructor. More...
 
void start (const G::ExecutableCommand &commandline)
 Starts the task by spawning a new process with the given command-line and also starting a thread to wait for it. More...
 
void stop ()
 Attempts to kill the spawned process and waits for it to terminate. More...
 

Friends

class GNet::TaskImp
 

Detailed Description

A class for running an exectuable in a separate process with an asychronous completion callback.

Definition at line 42 of file gtask.h.

Constructor & Destructor Documentation

GNet::Task::Task ( TaskCallback &  callback,
ExceptionHandler &  eh,
const std::string &  exec_error_format = std::string(),
const G::Identity &  id = G::Identity::invalid() 
)

Constructor for a start()able object.

The two trailing parameters are passed to the G::NewProcess class.

Definition at line 148 of file gtask.cpp.

GNet::Task::~Task ( )

Destructor.

Kills the spawned process and waits for it to terminate, where necessary.

Definition at line 158 of file gtask.cpp.

Member Function Documentation

void GNet::Task::start ( const G::ExecutableCommand &  commandline)

Starts the task by spawning a new process with the given command-line and also starting a thread to wait for it.

The wait thread signals completion of the child process via the event loop and the TaskCallback interface. Throws Busy if still busy from a prior call to start().

Definition at line 162 of file gtask.cpp.

void GNet::Task::stop ( )

Attempts to kill the spawned process and waits for it to terminate.

No task-done callback will be triggered.

Definition at line 171 of file gtask.cpp.


The documentation for this class was generated from the following files: