2016-07-14 19:16:42 +03:00
|
|
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
2013-02-26 01:20:02 +04:00
|
|
|
# vim: set filetype=python:
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2013-03-12 21:17:46 +04:00
|
|
|
XPIDL_SOURCES += [
|
|
|
|
'nsIEnvironment.idl',
|
|
|
|
'nsIEventTarget.idl',
|
2016-08-24 17:18:06 +03:00
|
|
|
'nsIIdlePeriod.idl',
|
2016-11-23 03:18:52 +03:00
|
|
|
'nsINamed.idl',
|
2013-03-12 21:17:46 +04:00
|
|
|
'nsIProcess.idl',
|
|
|
|
'nsIRunnable.idl',
|
2017-05-23 00:25:43 +03:00
|
|
|
'nsISerialEventTarget.idl',
|
2013-03-12 21:17:46 +04:00
|
|
|
'nsISupportsPriority.idl',
|
|
|
|
'nsIThread.idl',
|
|
|
|
'nsIThreadInternal.idl',
|
|
|
|
'nsIThreadManager.idl',
|
|
|
|
'nsIThreadPool.idl',
|
|
|
|
'nsITimer.idl',
|
|
|
|
]
|
|
|
|
|
2013-03-12 09:00:00 +04:00
|
|
|
XPIDL_MODULE = 'xpcom_threads'
|
|
|
|
|
2013-04-16 23:24:43 +04:00
|
|
|
EXPORTS += [
|
2017-01-20 22:13:57 +03:00
|
|
|
'MainThreadUtils.h',
|
2016-04-11 21:40:06 +03:00
|
|
|
'nsICancelableRunnable.h',
|
2017-05-16 18:18:33 +03:00
|
|
|
'nsIIdleRunnable.h',
|
2017-07-20 02:23:01 +03:00
|
|
|
'nsILabelableRunnable.h',
|
2013-07-09 06:15:34 +04:00
|
|
|
'nsMemoryPressure.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
'nsProcess.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'nsProxyRelease.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
'nsThread.h',
|
2018-01-28 10:41:36 +03:00
|
|
|
'nsThreadManager.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'nsThreadUtils.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
]
|
|
|
|
|
|
|
|
EXPORTS.mozilla += [
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'AbstractEventQueue.h',
|
2015-08-05 02:32:11 +03:00
|
|
|
'AbstractThread.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'BlockingResourceBase.h',
|
|
|
|
'CondVar.h',
|
2017-07-29 00:56:49 +03:00
|
|
|
'CooperativeThreadPool.h',
|
Bug 1382440 - Watch CPU usage in BHR r=froydnj
We would like to be able to see if a given hang in BHR occurred
under high CPU load, as this is an indication that the hang is
of less use to us, since it's likely that the external CPU use
is more responsible for it.
The way this works is fairly simple. We get the system CPU usage
on a scale from 0 to 1, and we get the current process's CPU
usage, also on a scale from 0 to 1, and we subtract the latter
from the former. We then compare this value to a threshold, which
is 1 - (1 / p), where p is the number of (virtual) cores on the
machine. This threshold might need to be tuned, so that we
require an entire physical core in order to not annotate the hang,
but for now it seemed the most reasonable line in the sand.
I should note that this considers CPU usage in child or parent
processes as external. While we are responsible for that CPU usage,
it still indicates that the stack we receive from BHR is of little
value to us, since the source of the actual hang is external to
that stack.
MozReview-Commit-ID: JkG53zq1MdY
--HG--
extra : rebase_source : 16553a9b5eac0a73cd1619c6ee01fa177ca60e58
2017-07-24 23:46:09 +03:00
|
|
|
'CPUUsageWatcher.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'DeadlockDetector.h',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'EventQueue.h',
|
2015-03-10 04:41:24 +03:00
|
|
|
'HangAnnotations.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
'HangMonitor.h',
|
2017-08-07 08:50:47 +03:00
|
|
|
'IdleTaskRunner.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
'LazyIdleThread.h',
|
2016-08-24 17:18:06 +03:00
|
|
|
'MainThreadIdlePeriod.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'Monitor.h',
|
2015-08-14 21:31:34 +03:00
|
|
|
'MozPromise.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'Mutex.h',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'Queue.h',
|
2017-03-14 21:05:51 +03:00
|
|
|
'RecursiveMutex.h',
|
2017-01-20 22:13:57 +03:00
|
|
|
'ReentrantMonitor.h',
|
2017-05-23 04:26:26 +03:00
|
|
|
'RWLock.h',
|
2017-07-29 00:56:49 +03:00
|
|
|
'Scheduler.h',
|
2017-03-09 23:32:32 +03:00
|
|
|
'SchedulerGroup.h',
|
2015-08-04 00:37:23 +03:00
|
|
|
'SharedThreadPool.h',
|
2015-08-18 20:31:16 +03:00
|
|
|
'StateMirroring.h',
|
|
|
|
'StateWatching.h',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'SynchronizedEventQueue.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
'SyncRunnable.h',
|
2017-01-19 03:53:36 +03:00
|
|
|
'SystemGroup.h',
|
2017-01-19 07:26:17 +03:00
|
|
|
'TaskCategory.h',
|
2015-08-05 02:32:11 +03:00
|
|
|
'TaskDispatcher.h',
|
2015-08-08 03:03:47 +03:00
|
|
|
'TaskQueue.h',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'ThreadEventQueue.h',
|
2016-11-07 23:30:17 +03:00
|
|
|
'ThrottledEventQueue.h',
|
2013-04-16 23:24:43 +04:00
|
|
|
]
|
|
|
|
|
2017-08-07 08:50:47 +03:00
|
|
|
SOURCES += [
|
|
|
|
'IdleTaskRunner.cpp',
|
|
|
|
]
|
|
|
|
|
2013-11-19 06:34:00 +04:00
|
|
|
UNIFIED_SOURCES += [
|
2015-08-05 02:32:11 +03:00
|
|
|
'AbstractThread.cpp',
|
2017-01-20 22:13:57 +03:00
|
|
|
'BlockingResourceBase.cpp',
|
2017-07-29 00:56:49 +03:00
|
|
|
'CooperativeThreadPool.cpp',
|
Bug 1382440 - Watch CPU usage in BHR r=froydnj
We would like to be able to see if a given hang in BHR occurred
under high CPU load, as this is an indication that the hang is
of less use to us, since it's likely that the external CPU use
is more responsible for it.
The way this works is fairly simple. We get the system CPU usage
on a scale from 0 to 1, and we get the current process's CPU
usage, also on a scale from 0 to 1, and we subtract the latter
from the former. We then compare this value to a threshold, which
is 1 - (1 / p), where p is the number of (virtual) cores on the
machine. This threshold might need to be tuned, so that we
require an entire physical core in order to not annotate the hang,
but for now it seemed the most reasonable line in the sand.
I should note that this considers CPU usage in child or parent
processes as external. While we are responsible for that CPU usage,
it still indicates that the stack we receive from BHR is of little
value to us, since the source of the actual hang is external to
that stack.
MozReview-Commit-ID: JkG53zq1MdY
--HG--
extra : rebase_source : 16553a9b5eac0a73cd1619c6ee01fa177ca60e58
2017-07-24 23:46:09 +03:00
|
|
|
'CPUUsageWatcher.cpp',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'EventQueue.cpp',
|
2015-03-10 04:41:24 +03:00
|
|
|
'HangAnnotations.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'HangMonitor.cpp',
|
2017-03-21 10:44:12 +03:00
|
|
|
'InputEventStatistics.cpp',
|
2017-07-29 00:56:49 +03:00
|
|
|
'LabeledEventQueue.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'LazyIdleThread.cpp',
|
2016-08-24 17:18:06 +03:00
|
|
|
'MainThreadIdlePeriod.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'nsEnvironment.cpp',
|
2017-09-13 06:59:35 +03:00
|
|
|
'nsILabelableRunnable.cpp',
|
2013-07-09 06:15:34 +04:00
|
|
|
'nsMemoryPressure.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'nsProcessCommon.cpp',
|
2017-01-20 22:13:57 +03:00
|
|
|
'nsProxyRelease.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'nsThread.cpp',
|
|
|
|
'nsThreadManager.cpp',
|
|
|
|
'nsThreadPool.cpp',
|
2017-01-20 22:13:57 +03:00
|
|
|
'nsThreadUtils.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
'nsTimerImpl.cpp',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'PrioritizedEventQueue.cpp',
|
2017-03-14 21:05:51 +03:00
|
|
|
'RecursiveMutex.cpp',
|
2017-05-23 04:26:26 +03:00
|
|
|
'RWLock.cpp',
|
2017-07-29 00:56:49 +03:00
|
|
|
'Scheduler.cpp',
|
2017-03-09 23:32:32 +03:00
|
|
|
'SchedulerGroup.cpp',
|
2015-08-04 00:37:23 +03:00
|
|
|
'SharedThreadPool.cpp',
|
2017-08-21 23:26:14 +03:00
|
|
|
'SynchronizedEventQueue.cpp',
|
2017-01-19 03:53:36 +03:00
|
|
|
'SystemGroup.cpp',
|
2015-08-08 03:03:47 +03:00
|
|
|
'TaskQueue.cpp',
|
Bug 1382922 - Refactor event queue to allow multiple implementations (r=erahm)
This patch refactors the nsThread event queue to clean it up and to make it easier to restructure. The fundamental concepts are as follows:
Each nsThread will have a pointer to a refcounted SynchronizedEventQueue. A SynchronizedEQ takes care of doing the locking and condition variable work when posting and popping events. For the actual storage of events, it delegates to an AbstractEventQueue data structure. It keeps a UniquePtr to the AbstractEventQueue that it uses for storage.
Both SynchronizedEQ and AbstractEventQueue are abstract classes. There is only one concrete implementation of SynchronizedEQ in this patch, which is called ThreadEventQueue. ThreadEventQueue uses locks and condition variables to post and pop events the same way nsThread does. It also encapsulates the functionality that DOM workers need to implement their special event loops (PushEventQueue and PopEventQueue). In later Quantum DOM work, I plan to have another SynchronizedEQ implementation for the main thread, called SchedulerEventQueue. It will have special code for the cooperatively scheduling threads in Quantum DOM.
There are two concrete implementations of AbstractEventQueue in this patch: EventQueue and PrioritizedEventQueue. EventQueue replaces the old nsEventQueue. The other AbstractEventQueue implementation is PrioritizedEventQueue, which uses multiple queues for different event priorities.
The final major piece here is ThreadEventTarget, which splits some of the code for posting events out of nsThread. Eventually, my plan is for multiple cooperatively scheduled nsThreads to be able to share a ThreadEventTarget. In this patch, though, each nsThread has its own ThreadEventTarget. The class's purpose is just to collect some related code together.
One final note: I tried to avoid virtual dispatch overhead as much as possible. Calls to SynchronizedEQ methods do use virtual dispatch, since I plan to use different implementations for different threads with Quantum DOM. But all the calls to EventQueue methods should be non-virtual. Although the methods are declared virtual, all the classes used are final and the concrete classes involved should all be known through templatization.
MozReview-Commit-ID: 9Evtr9oIJvx
2017-06-21 05:42:13 +03:00
|
|
|
'ThreadEventQueue.cpp',
|
|
|
|
'ThreadEventTarget.cpp',
|
2016-11-07 23:30:17 +03:00
|
|
|
'ThrottledEventQueue.cpp',
|
2013-10-24 03:05:43 +04:00
|
|
|
'TimerThread.cpp',
|
2013-04-24 01:54:15 +04:00
|
|
|
]
|
|
|
|
|
2013-09-12 16:15:51 +04:00
|
|
|
LOCAL_INCLUDES += [
|
|
|
|
'../build',
|
2014-07-15 22:12:59 +04:00
|
|
|
'/caps',
|
2014-07-28 21:30:21 +04:00
|
|
|
'/tools/profiler',
|
2013-09-12 16:15:51 +04:00
|
|
|
]
|
2013-11-19 06:47:14 +04:00
|
|
|
|
2014-07-23 03:37:51 +04:00
|
|
|
FINAL_LIBRARY = 'xul'
|
2013-10-23 16:01:24 +04:00
|
|
|
|
|
|
|
include('/ipc/chromium/chromium-config.mozbuild')
|