node-threads-a-gogo2 icon indicating copy to clipboard operation
node-threads-a-gogo2 copied to clipboard

I am writing a wrapper. But I have ERROR_ARG_1

Open benzmuircroft opened this issue 10 years ago • 1 comments

First, I found that in npm README.md you have a mistake

npm install threads_a_gogo

should be

npm install tagg2

you also have

require('threads_a_gogo'); // should be tagg2

secondly, I am trying to write a wrapper for tagg.create, but I keep getting the error

thread_obj.create first argument must be a run thread function or a  {poolsize:100, fastthread:false}

My wrapper is like this:

tagg.do=function(fun,args,callback){
    Function.prototype.getName=function(){return /function ([^(]*)/.exec( this+"" )[1];};
    args=JSON.stringify(args);
    this.create().eval(fun).eval((fun.getName()+'('+args+')'),callback);
    };

So I pass in the function as fun for the first eval, then I convert the args for the function to a string and get the function in the first eval as a string then combine the strings to execute in the second eval. the callback is simple...

Then I use it like this

function inAnotherThread(n){console.log('n='+n);}

tagg.do(inAnotherThread,1,function(){console.log('done!');});

Is the error talking about the first eval or the second?

I don't see why the typeof is wrong when:

function name(){console.log(1);}

function getTypeOf(fun){console.log(typeof fun);}

getTypeOf(name)

//result = function 

benzmuircroft avatar Aug 13 '14 14:08 benzmuircroft

you take the wrong arguments into tagg.create() function, you should use it like this: tagg.create(func, opt, cb) tagg.create not return tagg object,and it's not promise mode

DoubleSpout avatar Oct 03 '14 15:10 DoubleSpout