c++ - Node.js addon callback using member variables -


so i'm making addon node.js in: http://nodejs.org/api/addons.html#addons_wrapping_c_objects. however: class has pthread loops forever , performs callbacks via uv_async_send() suggested in http://nikhilm.github.io/uvbook/threads.html. callback function needs access non-static class variables, setting: async.data = (void*) this; , in callback function: myclass* obj = (myclass*)(handle->data);, can access data via: obj->myvar.

what happens though, callback function called after object has been destructed already. i'm wondering how prevent happening, preferably without need javascript code.

in case wonder why callback needs access member variables: it's buffer filled seperate thread, passed argument javascript callback.

thanks in advance.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -