Closed
Bug 947499
Opened 11 years ago
Closed 9 years ago
Create worker analogue to nsMainThreadPtrHolder
Categories
(Core :: DOM: Workers, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: nsm, Unassigned)
Details
Attachments
(1 file)
4.33 KB,
patch
|
Details | Diff | Splinter Review |
Bug 916893 uses a pattern similar to what nsMainThreadPtrHolder is designed for, except that the object is created on a worker thread, and held by the main thread and passed back to the worker to be released.
I'm going to modify nsMainThreadPtrHolder to be nsOwningThreadPtrHolder, which will assert accesses to the thread the object was created on, and release on that specific thread. It will hold a pointer to the creating thread instead of using the current NS_GetMainThread() utility functions.
Another option is to have a separate nsWorkerThreadPtrHolder, so that the extra pointer space is only used by worker specific code, and existing code using nsMainThreadPtrHolder can save that.
bholley, any thoughts on which option would be better?
Reporter | ||
Updated•11 years ago
|
Flags: needinfo?(bobbyholley+bmo)
Comment 1•11 years ago
|
||
I'll defer to bsmedberg, since this is his module.
Flags: needinfo?(bobbyholley+bmo) → needinfo?(benjamin)
Comment 2•11 years ago
|
||
NS_IsMainThread is very fast because it's a single TLS lookup. Is PR_GetCurrentThread equivalently fast? This would at least cause nsMainThreadPtrHolder to be an extra word, which may not be a big deal because we don't use it that much.
Flags: needinfo?(benjamin)
Comment 3•11 years ago
|
||
(In reply to comment #2)
> NS_IsMainThread is very fast because it's a single TLS lookup. Is
> PR_GetCurrentThread equivalently fast? This would at least cause
> nsMainThreadPtrHolder to be an extra word, which may not be a big deal because
> we don't use it that much.
PR_GetCurrentThread uses pthread_getspecific on pthreads and a __declspec(thread) variable on Windows, so it should be equally fast.
Reporter | ||
Comment 4•11 years ago
|
||
Unfortunately the first option won't work. Workers have there own event loop which needs WorkerRunnable's, so nsProxyReleaseEvent can't be used. Similarly using just the current thread is not enough, since the WorkerThreadPtrHolder<> has to maintain a reference to the WorkerPrivate instead.
Reporter | ||
Comment 5•11 years ago
|
||
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #4)
> which needs WorkerRunnable's
which need WorkerRunnables.
Reporter | ||
Comment 6•11 years ago
|
||
Changed bug purpose to reflect changed and restricted use case. The (upcoming) patch for this is no longer useful for non-worker non-main threads.
Component: XPCOM → DOM: Workers
Summary: Generalize nsMainThreadPtrHolder to any thread. → Create worker analogue to nsMainThreadPtrHolder
Reporter | ||
Comment 7•11 years ago
|
||
I ended up not needing this since the concept of features and worker lifetime restrictions makes it complicated to manage worker->main thread communication.
That is something not easily generalizable. Feel free to use this if its relevant for something else.
Reporter | ||
Updated•11 years ago
|
Assignee: nobody → nsm.nikhil
Reporter | ||
Updated•11 years ago
|
Assignee: nsm.nikhil → nobody
Reporter | ||
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•