stolosapo / noise-kernel Goto Github PK
View Code? Open in Web Editor NEWA simple C++ library with many goodies... like Threads, Tasks, Arguments, Observables, GPIO and more
License: GNU General Public License v3.0
A simple C++ library with many goodies... like Threads, Tasks, Arguments, Observables, GPIO and more
License: GNU General Public License v3.0
In Thread::TaskRunner::runTask
. Should also include RuntimeException
, DomainException
here:
void* TaskRunner::runTask(string fullTaskName, void* data)
{
string taskName = getTaskFromParametrizedCommand(fullTaskName);
vector<string> params = getParamsFromParametrizedCommand(taskName);
ThreadDelegate delegate = tasks->get(taskName);
if (delegate == NULL)
{
return NULL;
}
Task* context = new Task(taskName, params, NULL, data);
void* result = NULL;
try
{
result = delegate(context);
}
--> catch(exception& e)
{
delete context;
throw e;
}
delete context;
return result;
}
When running a new Task
from a TaskRunner
this Task
does not know the original full task name (i.e. taskName?params=X).
Of course this could be inferred from the taskName and the params, but is good to also have it in it's original state.
in TaskRunner.cpp
...
void* TaskRunner::runTask(string fullTaskName, void* data)
{
string taskName = getTaskFromParametrizedCommand(fullTaskName);
vector<string> params = getParamsFromParametrizedCommand(taskName);
ThreadDelegate delegate = tasks->get(taskName);
if (delegate == NULL)
{
return NULL;
}
// Maybe here should also include the fullTaskName
Task* context = new Task(taskName, params, NULL, data);
void* result = NULL;
try
{
result = delegate(context);
}
catch(exception& e)
{
delete context;
throw e;
}
delete context;
return result;
}
...
When help
text is shown in the cout
should be correctly aligned
It's good to be able to underline type of a Task, so maybe it's good to have something like:
template <typename T>
class Task
{
private:
...
T* data;
public:
Task(string taskName, vector<string> params, Thread* runningThread, T* data);
...
static T* unwrap(void* task);
T* getData();
};
...
template <typename T>
T* Task<T>::unwrap(void* task)
{
Task<T> *t = (Task<T>*) task;
return t->getData();
};
...
and also:
template <typename T>
class TaskRunner
{
...
public:
...
virtual void* runTask(string task, T* data);
};
...
template <typename T>
void* TaskRunner<T>::runTask(string fullTaskName, T* data)
{
string taskName = getTaskFromParametrizedCommand(fullTaskName);
vector<string> params = getParamsFromParametrizedCommand(taskName);
ThreadDelegate delegate = tasks->get(taskName);
if (delegate == NULL)
{
return NULL;
}
Task<T>* context = new Task<T>(taskName, params, NULL, data);
void* result = NULL;
try
{
result = delegate(context);
}
catch(exception& e)
{
delete context;
throw e;
}
delete context;
return result;
}
...
In ArgumentAdapter
is good to have a method that identify if any or some arguments passed
Parsed from the wrong string
in TaskRunner.cpp
...
void* TaskRunner::runTask(string fullTaskName, void* data)
{
string taskName = getTaskFromParametrizedCommand(fullTaskName);
// Here should be passed the 'fullTaskName' instead of 'taskName'
vector<string> params = getParamsFromParametrizedCommand(taskName);
ThreadDelegate delegate = tasks->get(taskName);
if (delegate == NULL)
{
return NULL;
}
Task* context = new Task(taskName, params, NULL, data);
void* result = NULL;
try
{
result = delegate(context);
}
catch(exception& e)
{
delete context;
throw e;
}
delete context;
return result;
}
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.