Code Monkey home page Code Monkey logo

noise-kernel's People

Contributors

stolosapo avatar

Watchers

 avatar

noise-kernel's Issues

`exception` does not propagated correctly

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;
}

`Task`s does not contain the original full command (including params)

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;
}
...

Make `Task` generic

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;
}
...

`Task`s does not contain parameters

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;
}
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.