Closed
Bug 617251
Opened 14 years ago
Closed 11 years ago
Can't send strings to threads
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: erikvvold, Unassigned)
References
Details
My extension Scriptish https://addons.mozilla.org/en-US/firefox/addon/231203/ implements Workers using threads which pass strings between threads, which no longer works because of bug 608142 which offers no alternative method to implement this.
Comment 1•14 years ago
|
||
We should be able to make this work for strings specifically by copying the string, I'd think. Performance would possibly suck, but...
Comment 2•14 years ago
|
||
Yeah, we can definitely allow strings through here. Erik, does that fix your use case?
(In reply to comment #2) > Yeah, we can definitely allow strings through here. Erik, does that fix your > use case? Yes that should be all that I need.
Comment 4•14 years ago
|
||
Just to be clear though, you can't send closures across. How do you execute code on a thread right now without workers?
(In reply to comment #4) > Just to be clear though, you can't send closures across. How do you execute > code on a thread right now without workers? https://github.com/erikvold/scriptish/blob/master/extension/modules/api/GM_worker.js#L156 I took a closer look at my implementation and have been thinking about this all night, and I am sharing objects atm. At first I thought I could just pass messages + signatures to a singleton dispatcher, instead of making dynamic dispatchers as I am now, but now I'm wondering how to pass the string from the background thread to the dispatcher in the main thread, and atm I can't think of a way to do that..
Comment 6•14 years ago
|
||
(In reply to comment #5) > ... but now I'm > wondering how to pass the string from the background thread to the dispatcher > in the main thread ... That's not the actual problem here: While you can still create a background thread using newThread() you cannot (from js) dispatch any runnable code to this new thread. So in fact, you don't have a background thread (here: javascript implementation of nsIRunnable running on a background thread) that needs to dispatch anything back to the main thread ;) In your code fake_worker.run is in fact never called as you're trying to execute instances of it on a |newThread(0)|. And that's exactly what bug 608142 doesn't permit any longer. Your |dispatch(this, ...)| fails silently[1]. The nsIThreadManager API is dead when it comes to creating new threads to execute js-implemented nsIRunnables. There aren't any full-featured alternatives: Neither Workers nor JetPack processes allow XPCOM access. [1] https://github.com/erikvold/scriptish/blob/master/extension/modules/api/GM_worker.js#L74 Assuming this.thread points to a new thread, like it does right now.
(In reply to comment #6) > (In reply to comment #5) > > ... but now I'm > > wondering how to pass the string from the background thread to the dispatcher > > in the main thread ... > > That's not the actual problem here: While you can still create a background > thread using newThread() you cannot (from js) dispatch any runnable code to > this new thread. So what can you do with a thread then? > So in fact, you don't have a background thread that > needs to dispatch anything back to the main thread ;) huh?
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•