2016-03-12 13:50:43 -05:00
|
|
|
#ifndef INCLUDED_TaskStub
|
|
|
|
#define INCLUDED_TaskStub
|
|
|
|
|
|
|
|
#include "PacketStream.h"
|
|
|
|
|
|
|
|
#include <v8.h>
|
|
|
|
|
|
|
|
class Task;
|
|
|
|
|
|
|
|
typedef int taskid_t;
|
|
|
|
|
|
|
|
class TaskStub {
|
|
|
|
public:
|
|
|
|
void ref();
|
|
|
|
void release();
|
|
|
|
|
|
|
|
static void create(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static TaskStub* createParent(Task* task, uv_file file);
|
|
|
|
static void initialize();
|
|
|
|
|
|
|
|
taskid_t getId() { return _id; }
|
|
|
|
Task* getOwner() { return _owner; }
|
|
|
|
v8::Handle<v8::Object> getTaskObject();
|
|
|
|
PacketStream& getStream() { return _stream; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
v8::Persistent<v8::Object> _taskObject;
|
|
|
|
int _refCount = 1;
|
|
|
|
|
|
|
|
Task* _owner = 0;
|
|
|
|
PacketStream _stream;
|
|
|
|
taskid_t _id = -1;
|
|
|
|
uv_process_t _process;
|
|
|
|
|
|
|
|
v8::Persistent<v8::Function, v8::CopyablePersistentTraits<v8::Function> > _onExit;
|
|
|
|
|
|
|
|
static bool _determinedExecutable;
|
|
|
|
static char _executable[1024];
|
|
|
|
|
|
|
|
TaskStub();
|
|
|
|
|
|
|
|
static TaskStub* get(v8::Handle<v8::Value> object);
|
|
|
|
|
|
|
|
static void getExports(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void setImports(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
|
2016-04-16 17:30:52 -04:00
|
|
|
static void setRequires(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2016-04-09 11:24:48 -04:00
|
|
|
|
2016-03-12 13:50:43 -05:00
|
|
|
static void getOnExit(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
|
|
static void setOnExit(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& args);
|
|
|
|
|
|
|
|
static void activate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void execute(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void kill(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void statistics(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
|
2016-07-23 06:54:10 -04:00
|
|
|
static void onRelease(const v8::WeakCallbackInfo<TaskStub>& data);
|
2016-03-12 13:50:43 -05:00
|
|
|
|
|
|
|
static void onProcessExit(uv_process_t* process, int64_t status, int terminationSignal);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|