Re: [v8-users] API to intercept Promises in V8

2020-02-13 Thread Ben Noordhuis
On Wed, Feb 12, 2020 at 2:31 PM Darin Dimitrov wrote: > > I managed to get this working by replacing the native Promise object by > executing the following script: > > global.Promise = new Proxy(global.Promise, { > construct: function(target, args) { > const origFunc = arg

Re: [v8-users] API to intercept Promises in V8

2020-02-12 Thread Darin Dimitrov
I managed to get this working by replacing the native Promise object by executing the following script: global.Promise = new Proxy(global.Promise, { construct: function(target, args) { const origFunc = args[0]; return new target(function(resolve, reject) {

Re: [v8-users] API to intercept Promises in V8

2020-02-11 Thread Darin Dimitrov
Hi Ben, Thanks for the reply. My program is actually a MacOS application and it uses its SDK to create threads. I am using v8::Locker to ensure that only one thread is accessing the isolate. And this works quite well. I can also use the MacOS SDK to schedule some work on any thread. The problem

Re: [v8-users] API to intercept Promises in V8

2020-02-11 Thread Ben Noordhuis
On Tue, Feb 11, 2020 at 8:42 PM Darin Dimitrov wrote: > > I am embedding V8 in my C++ application and I have registered a custom "test" > function on the global object taking a callback as parameter: > > test(function() { > console.log("callback"); > }); > > The "test" function starts a new t

[v8-users] API to intercept Promises in V8

2020-02-11 Thread Darin Dimitrov
I am embedding V8 in my C++ application and I have registered a custom "test" function on the global object taking a callback as parameter: test(function() { console.log("callback"); }); The "test" function starts a new thread and executes the callback on this thread. Now I can wrap