[3:46]<Dantman> T_T Crap, I need tank tread physics... (Not surface area and whatever... Having two parallel forces and calculating the rotation and directional movement it causes on the object they are attached to) [10:23]<ondras> ryah: ? [11:55]<ryah> ondras: ? [12:37]<ondras> ryah: I have to leave now, but can you please - in the meantime - slightly (on query) explain to me how setTimeout is implemented in node? [13:09]<veged> ondras: are there any functions about paths of modules? in case i wanna know where is file lookaped by requiere()/include() [13:09]<veged> in v8cgi ^_^ [14:50]<ryah> ondras: using select() (well, not actually, but similarly) [14:54]<ryah> ondras: so you just loop in there until the timeout happens. it requires your thread to be designed around an event loop though [15:16]<ondras> ryah: hm, I am a novice in this area... can you please be more specific? [15:16]<ondras> veged: require.paths [15:17]<ryah> ondras: you have to have an event loop of some sort [15:18]<ryah> so that your thread sits in some select() or event_loop() function most of the time [15:18]<ryah> then you get callbacks out of that loop [15:19]<ryah> i don't know how apache modules work, so i can't say much more [15:19]<ondras> okay [15:19]<ondras> so [15:19]<ondras> in v8, you create v8::Script::New("jscode") [15:20]<ondras> and than you ->Run() that thing [15:20]<veged> ondras: system.stdout(require.paths + '\n'); produce 'undefined' [15:20]<ryah> yeah [15:20]<ryah> after i run it for the frist time, i enter the event loop [15:20]<ondras> veged: require.paths is only in recent svn revisions... [15:20]<ondras> veged: 0.7.0. release is old and uses Config.libraryPath iirc [15:21]<ondras> ryah: so "jscode" cannot be arbitrary js string in your case? [15:21]<ondras> this still puzzles me I have to say :) [15:21]<ryah> ondras: http://github.com/ry/node/blob/master/src/node.cc#L859-882 [15:23]<veged> ondras: oh yeh, in r646 already works [15:23]<ryah> ondras: in node the script that's run is always src/node.js which in turn loads the ARGV[1] [15:24]<ondras> ryah: and node.js is executed in node::Load ? [15:24]<ryah> ondras: yeah [15:24]<ryah> ondras: http://github.com/ry/node/blob/master/src/node.cc#L859-882 [15:24]<ryah> er [15:24]<ryah> http://github.com/ry/node/blob/master/src/node.cc#L724 [15:26]<ondras> aha [15:26]<ondras> maybe I am slowly getting into that [15:26]<ondras> :) [15:27]<ondras> so, you execute all the JS code "immediately", before starting the main event loop [15:27]<ryah> right [15:27]<ryah> well - technically ARGV[1] is executed after the event loop is started [15:28]<ryah> but it could be executed before [15:29]<ashb> do you have interuppting signals at all? [15:29]<ryah> ashb: what do you mean? [15:30]<ashb> i..e like setTimeout but that runs whne the timeout fires, not when the timeout fires after but only when there's no other code running [15:30]<ondras> ryah: still - if the argv[1] contains "setTimeout(code, 100); for (var i=0;i<1e10;i++) {}", how is this handled? [15:31]<ryah> ashb: hmm.. not sure what you mean - no, i don't think so [15:31]<ashb> setTimeout(10, fn); while (true) { /* block */ } [15:31]<ashb> will fn ever fire? [15:31]<ryah> ondras: then the timeout won't be called for a long time [15:31]<ondras> ok [15:31]<ondras> so I finally understand [15:31]<ryah> ashb: no [15:32]<ashb> ditto [15:32]<ondras> all your c++ callbacks then check for timeouts [15:32]<ashb> not sur eits needed - just wanted to get a feel for the behaviour [15:32]<ondras> ryah: so basically every time control is passed from v8 to your c++ code, timeouts might get executed? [15:32]<ryah> ondras: not exactly - i get special callbacks for timeouts [15:33]<ashb> damn. mail.app is still beachballing when ever i try to compose something [15:33]<ondras> ryah: ok, so you get notified when timeouts should be executed, but you can execute them only when v8 lets your c++ code to act? [15:34]<ryah> ondras: right [15:34]<ryah> ondras: node retruns to the event loop (c++) very often [15:34]<ondras> because if you would try to execute them when notification comes, the code would crash [15:34]<ondras> by violating threading or so [15:34]<ondras> ? [15:34]<ryah> nothing blocks, so it's only in js for nanoseconds [15:34]<ondras> hmm [15:35]<ondras> so, what prevents you from executing timeout when you receive your notification? [15:35]<ryah> unless you do while(true) {} :) [15:36]<ondras> ryah: ^ ? [15:36]<ryah> ondras: the timeout notification comes synchronously [15:36]<ryah> it's not asynchronous to the main thread [15:37]<ryah> theres not problem to call the js callback immediately [15:37]<ryah> other things, like signal handlers, which are async - get marshaled into the main thread via a pipe [15:38]<ondras> hmm [15:39]<ondras> it is still somewhat hard for me to get compatible with this approach [15:39]<ondras> but I hope I got the main point [15:39]<ryah> the main point is you must use select() [15:39]<ryah> (or whatever) [15:39]<ryah> everything falls out easily from that [15:39]<ryah> select() must be called after each callback [15:39]<ashb> the event loop doens't have to be started from C++ either of course [15:40]<ashb> it can be require('event').run() or similar [15:40]<ryah> right, no [15:41]<ondras> hm [15:41]<ondras> select() [15:41]<ondras> something new for me [15:41]* ondras is ashamed [15:41]<ryah> ondras: good reading: http://www.kegel.com/c10k.html [15:43]<ondras> thanks, will read [15:43]<ondras> I studied the manpage for select(), but I don't see how it relates to this [15:43]<ondras> will study more. [15:44]<frodenius> does v8 have some kind of script timeout, so those infinite loops could be aborted? [15:44]* ondras is not aware of any [15:45]<ashb> spidermonkey does i think [15:46]<ashb> or at least a function you can call from another thread to signal a change to interupt it [15:47]<ashb> https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback [15:48]<ashb> i think thats the right one [15:48]<ashb> they changed it recently [15:49]<frodenius> thats cool [15:49]<ashb> aparently i have 65045 messages spread across all my mailboxes [15:50]<ashb> http://groups.google.com/group/mozilla.dev.tech.js-engine/browse_thread/thread/a4d1fe147761aacb/e61d2592faf4ef72?lnk=gst&q=js_setoperationcallback [15:50]<ashb> so yeah - that JS_SetOperationCallback is the right one [15:53]<ondras> node callbacks don't look like something special, "select() must be called after each callback" is puzzling me. [15:53]<ondras> this looks like a completely unexplored area to me [15:53]<ashb> ondras: so basically [15:54]<ashb> select() is a way to wait for an event on a socket, or for a givne timeout, without eating CPU [15:54]<ondras> yes [15:54]<ondras> that I understand [15:55]<frodenius> ahh v8::v8::TerminateExecution() [15:56]<ondras> frodenius: but this is only used to notfiy thread A from thread B that it should be interrupted [15:56]<ondras> *notify [15:57]<frodenius> well, it throws an exception that is uncatchable by js code [15:58]<frodenius> as long as your c++ code does not ignore that [15:59]<ondras> but you have to somehow detect that the code is running for too long [17:37]<veged> what the best way write commonjs modules for work in both, browser and js-engine? [17:39]<dom> make sure you don't use window or document [17:40]<dom> when exporting your interface use something like: [17:40]<dom> http://github.com/jquery/qunit/blob/master/qunit/qunit.js#L405-411 [17:41]<dom> of course extend() is only needed if you want to expose properties too at the global level [17:41]<dom> otherwise just: [17:41]<dom> if ( exports ) exports.foo = foo; else window.foo = foo; [17:43]<veged> ok, thnx [19:52]<veged> how load module by require()/include() with custom global object? in case when loaded module need something but not contain require()/include() by self, and i could provide it from upper level [19:53]<ondras> can you be more specific? [19:54]<veged> ok [19:54]<veged> main.js [19:54]<veged> include('./m1') [19:54]<veged> m1.js [19:54]<veged> var b = MyFunc(); [19:54]<veged> in m1.js MyFunc undefined [19:54]<veged> but i can provide it from main.js [19:55]<ondras> that is a cyclic dependency [19:55]<ondras> imho these should not happen. [19:55]<veged> something like: [19:55]<veged> main.js [19:55]<veged> include('./m1', {MyFunc: function(){return true}}) [19:55]<ondras> nono [19:55]<ondras> if MyFunc is in module [19:55]<ondras> then in m1.js [19:55]<ondras> require("./myfunc").MyFunc() [19:56]<ondras> (myfunc should be in module, if it is required by m1) [19:56]<ondras> afk now [19:57]<veged> if i have many variants of MyFunc and it's various in various cases [19:58]<veged> if i can provide different MyFunc in different cases ? it would be cool [19:59]<veged> i can do some like [19:59]<veged> include('./m1', {MyFunc: (CASE? require('./myfunc1') : require('./myfunc2')).MyFunc) [20:00]<veged> and m1.js does not know about MyFunc definition, but use it [20:05]<veged> it like functions and parameters ? modules should be parametrized [20:36]<ashb> so of the binary proposals, which are implemented, and by what platforms? [20:37]<ashb> ondras: do you have any binary classes? [20:39]<ashb> a quick search through your source implies not [20:46]* ashb wonds if kriszyp and kriskowal are the same person. [20:46]<ashb> I never seem them on irc at the same time [21:19]<veged> dom: is it correct use instead of [21:19]<veged> (function(window) { ?. })(this); [21:19]<veged> wrapper like this: [21:19]<veged> (function(exports) { ? })(typeof exports === 'undefined' ? this : exports); [21:19]<veged> and use exports "natively" without "if" statement [21:20]<dom> window in this case is a parameter [21:20]<dom> (function(top_level_object){ ... })( exports || window ); [21:20]<dom> something like that [21:21]<veged> (function(exports, window) { ? })(typeof exports === 'undefined' ? this : exports, window); [21:21]<veged> (exports || window) maybe undef => (exports || window || this) [21:22]<dom> anyway, I wouldn't pass in anything personally [21:22]<dom> but it's your call [21:37]<veged> ondras: why v8cgi provide for code [21:37]<veged> var b = blabla || 'default'; [21:37]<veged> message 1: ReferenceError: blabla is not defined [21:37]<veged> ? [21:54]<ondras> veged: ? [21:54]<ondras> what is wrong there? [21:54]<ashb> thats how JS behaves, not v8cgi specifically [21:54]<ondras> exactly. [21:55]<veged> ups [21:55]<veged> sorry [21:55]<veged> mea culpa [21:59]<ryah_away> ondras: [21:59]<ryah_away> I'm not sure if this is working on x64 (although the test passes); are [21:59]<ryah_away> oops [21:59]<ryah_away> ondras: http://codereview.chromium.org/391068 [22:00]<ashb> ryah_away: btw - your blob patch to v8 [22:00]<ashb> ah which is that [22:00]<ashb> ryah_away: as for a JS api - there's been discussion on some w3c and the es-discuss lists about a binary api [22:01]<ondras> ryah_away: very nice, thanks! [22:01]* ondras going to sleep [22:03]<ondras> detach [22:07]<veged> ondras: real source of question code "var b = exports || 'default';" ? in my old v8cgi version exports undefined in top level .js ? but in recent version all ok [22:07]<ashb> yeah - vucgi only got exports/commonjs modules a few weeks ago [22:07]<veged> ondras: btw, what about compilation current svn version on macosx? [22:10]<ryah_away> ashb: yeah, i guess i'll look at that soon if my blob patch is accepted