Open
Bug 1796566
Opened 3 years ago
Updated 1 year ago
Make it easier to use async shutdown blockers from C++
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
NEW
People
(Reporter: jstutte, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 obsolete file)
No description provided.
| Reporter | ||
Comment 1•3 years ago
|
||
Depends on D143343
| Reporter | ||
Comment 2•3 years ago
|
||
Bug 1709184 gives some hints for what we probably want in terms of thread-safety here:
- Singletons can be instantiated off-main-thread, thus the used base classes need to be thread safe.
- If off-main-thread there is potential for races between checking the shutdown phase and actually adding a blocker for it that might lead to problems. We might want to think about an appropriate mutex that prevents us from advancing the shutdown phase when in this state.
- We might want to have guarantees on which thread our
OnInstantiationandOnShutdowncallbacks are actually executed. I'd assume that we want to callOnShutdownon the same owning event target on which we called our firstOnInstantiation(accounting also for thread pool situations) ?
Updated•3 years ago
|
Attachment #9299772 -
Attachment description: WIP: Bug 1796566 - Have a base class for async shutdown managed lazy instantiated singletons. → WIP: Bug 1796566 - Have a base class for async shutdown managed and lazily instantiated singletons.
| Reporter | ||
Comment 3•3 years ago
|
||
Copying over nika's suggestion to not bury it in the patch's comments:
Random idea for an ergonomic wrapper around async shutdown blockers vaguely inspired by the js interface:
using BlockerFunc = MoveOnlyFunction<RefPtr<GenericPromise>()>;
using ClearBlockerFunc = std::function<void()>;
ClearBlockerFunc AddAsyncShutdownBlocker(BlockerFunc aBlocker);
You pass it a closure which returns a GenericPromise which must resolve before advancing shutdown phase, and it returns a function to unregister that closure
We could also have a version which takes a bare RefPtr<GenericPromise> and just waits for it to resolve or reject, then removes it
Updated•3 years ago
|
Attachment #9299772 -
Attachment is obsolete: true
| Reporter | ||
Updated•1 year ago
|
Summary: Have a base class for C++ singletons that uses async shutdown blockers → Make it easier to use async shutdown blockers from C++
You need to log in
before you can comment on or make changes to this bug.
Description
•