16 Commits

Author SHA1 Message Date
tommi
83722268d6 TaskQueue[Win] DOS handling
BUG=webrtc:7341

Review-Url: https://codereview.webrtc.org/2750853002
Cr-Commit-Position: refs/heads/master@{#17242}
2017-03-15 11:36:29 +00:00
tommi
0b942150d3 Refactor Windows TaskQueue code to only need a single high res timer.
BUG=webrtc:7151

Review-Url: https://codereview.webrtc.org/2733723002
Cr-Commit-Position: refs/heads/master@{#17170}
2017-03-10 17:33:53 +00:00
tommi
5bdee47ede Increase tick precision in TaskQueue on Windows 64.
Hopefully this will reduce the flakiness of PostDelayedTask.

BUG=none

Review-Url: https://codereview.webrtc.org/2728663008
Cr-Commit-Position: refs/heads/master@{#17001}
2017-03-03 13:20:12 +00:00
tommi
c9bb7918f6 Add support for priorities to TaskQueue.
BUG=webrtc:7216

Review-Url: https://codereview.webrtc.org/2708353003
Cr-Commit-Position: refs/heads/master@{#16834}
2017-02-24 18:42:14 +00:00
tommi
0f8b403eb5 Introduce a new constructor to PlatformThread.
The new constructor introduces two new changes:

* Support specifying thread priority at construction time.
  - Moving forward, the SetPriority() method will be removed.
* New thread function type.
  - The new type has 'void' as a return type and a polling loop
    inside PlatformThread, is not used.

The old function type is still supported until all places have been moved over.

In this CL, the first steps towards deprecating the old mechanism are taken
by moving parts of the code that were simple to move, over to the new callback
type.

BUG=webrtc:7187

Review-Url: https://codereview.webrtc.org/2708723003
Cr-Commit-Position: refs/heads/master@{#16779}
2017-02-22 19:22:05 +00:00
tommi
f9d9154808 Add support for multimedia timers to TaskQueue on Windows.
Multimedia timers are higher precision than WM_TIMER, but they're also
a limited resource and more costly. So this implementation is a best
effort implementation that falls back on WM_TIMER when multimedia
timers aren't available.

A possible future change could be to make high precision timers in a
TaskQueue, optional. The reason for doing so would be for TaskQueues
that don't need high precision timers, won't eat up timers from TQ
instances that really need it.

BUG=webrtc:7151

Review-Url: https://codereview.webrtc.org/2691973002
Cr-Commit-Position: refs/heads/master@{#16661}
2017-02-17 10:47:11 +00:00
kwiberg
352444fcac RTC_[D]CHECK_op: Remove superfluous casts
There's no longer any need to make the two arguments have the same
signedness, so we can remove a bunch of superfluous (and sometimes
dangerous) casts.

It turned out I also had to fix the safe_cmp functions to properly handle
enums that are implicitly convertible to integers.

NOPRESUBMIT=true
BUG=webrtc:6645

Review-Url: https://codereview.webrtc.org/2534683002
Cr-Commit-Position: refs/heads/master@{#15281}
2016-11-28 23:59:03 +00:00
tommi
b89257a51b Handle initialization race in TaskQueue on Windows, discovered by drmemory.
The issue was that if the main entry routine of the thread would get called before the first APC, the thread would hang on a GetMessage() call and the APC sent to initialize the thread, would never run.

BUG=

Review-Url: https://codereview.webrtc.org/2139723003
Cr-Commit-Position: refs/heads/master@{#13438}
2016-07-12 08:24:41 +00:00
tommi
42883f8b85 Revert of Attempt to figure out what the issue is on the Win10 FYI build bot in content_browsertests. (patchset #1 id:1 of https://codereview.webrtc.org/2063313003/ )
Reason for revert:
Reverting after experiment.  What seems to happen is that the thread can't be stopped when PostThreadMessage fails with this error code (or lack thereof).

Original issue's description:
> Attempt to figure out what the issue is on the Win10 FYI build bot in content_browsertests.
> Check for the case when PostThreadMessage returns false but GetLastError returns ERROR_SUCCESS.
>
> TBR=olka
> NOTRY=true
>
> Committed: https://crrev.com/e11041159d6e66fb25c2e045ad1558fc99d2d6cd
> Cr-Commit-Position: refs/heads/master@{#13143}

TBR=olka@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.webrtc.org/2067013003
Cr-Commit-Position: refs/heads/master@{#13147}
2016-06-14 23:06:35 +00:00
tommi
e11041159d Attempt to figure out what the issue is on the Win10 FYI build bot in content_browsertests.
Check for the case when PostThreadMessage returns false but GetLastError returns ERROR_SUCCESS.

TBR=olka
NOTRY=true

Review-Url: https://codereview.webrtc.org/2063313003
Cr-Commit-Position: refs/heads/master@{#13143}
2016-06-14 21:38:04 +00:00
tommi
8b06ec0b71 Change RTC_CHECK to RTC_CHECK_EQ for improved printout of GetLastError.
TBR=olka@webrtc.org
NOTRY=true

Review-Url: https://codereview.webrtc.org/2061923004
Cr-Commit-Position: refs/heads/master@{#13134}
2016-06-14 15:38:14 +00:00
tommi
c06b133b29 Reland of New task queueing primitive for async tasks: TaskQueue.
New task queueing primitive for async tasks: TaskQueue.
TaskQueue is a new way to asynchronously execute tasks sequentially
in a thread safe manner with minimal locking.  The implementation
uses OS supported APIs to do this that are compatible with async IO
notifications from things like sockets and files.
This class is a part of rtc_base_approved, so can be used by both
the webrtc and libjingle parts of the WebRTC library.  Moving forward,
we can replace rtc::Thread and webrtc::ProcessThread with this implementation.
NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
which means that tasks might execute on different threads depending on
what's the most efficient thing to do.

TBR=perkj@webrtc.org,phoglund@webrtc.org

Review-Url: https://codereview.webrtc.org/1984503002
Cr-Commit-Position: refs/heads/master@{#12749}
2016-05-14 18:31:49 +00:00
tommi
3f90087ce8 Revert of New task queueing primitive for async tasks: TaskQueue. (patchset #8 id:330001 of https://codereview.webrtc.org/1927133004/ )
Reason for revert:
sigh.  Have to revert again as there seems to have have been some change made for pnacl and CrOS.

Original issue's description:
> Reland of New task queueing primitive for async tasks: TaskQueue. (patchset #1 id:1 of https://codereview.webrtc.org/1935483002/ )
>
> New task queueing primitive for async tasks: TaskQueue.
> TaskQueue is a new way to asynchronously execute tasks sequentially
> in a thread safe manner with minimal locking.  The implementation
> uses OS supported APIs to do this that are compatible with async IO
> notifications from things like sockets and files.
>
> This class is a part of rtc_base_approved, so can be used by both
> the webrtc and libjingle parts of the WebRTC library.  Moving forward,
> we can replace rtc::Thread and webrtc::ProcessThread with this implementation.
>
> NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
> run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
> which means that tasks might execute on different threads depending on
> what's the most efficient thing to do.
>
> TBR=perkj@webrtc.org
>
> Committed: https://crrev.com/65d1f2aba216d077c6d22488f03e56984aef1c68
> Cr-Commit-Position: refs/heads/master@{#12737}

TBR=perkj@webrtc.org,phoglund@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.webrtc.org/1981573002
Cr-Commit-Position: refs/heads/master@{#12738}
2016-05-13 21:33:39 +00:00
tommi
65d1f2aba2 Reland of New task queueing primitive for async tasks: TaskQueue. (patchset #1 id:1 of https://codereview.webrtc.org/1935483002/ )
New task queueing primitive for async tasks: TaskQueue.
TaskQueue is a new way to asynchronously execute tasks sequentially
in a thread safe manner with minimal locking.  The implementation
uses OS supported APIs to do this that are compatible with async IO
notifications from things like sockets and files.

This class is a part of rtc_base_approved, so can be used by both
the webrtc and libjingle parts of the WebRTC library.  Moving forward,
we can replace rtc::Thread and webrtc::ProcessThread with this implementation.

NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
which means that tasks might execute on different threads depending on
what's the most efficient thing to do.

TBR=perkj@webrtc.org

Review-Url: https://codereview.webrtc.org/1927133004
Cr-Commit-Position: refs/heads/master@{#12737}
2016-05-13 20:05:05 +00:00
tommi
b296d0591c Revert of New task queueing primitive for async tasks: TaskQueue. (patchset #5 id:80001 of https://codereview.webrtc.org/1919733002/ )
Reason for revert:
Reverting this temporarily while I figure out the issues with the Chrome on android GN debug build.

Original issue's description:
> New task queueing primitive for async tasks: TaskQueue.
> TaskQueue is a new way to asynchronously execute tasks sequentially
> in a thread safe manner with minimal locking.  The implementation
> uses OS supported APIs to do this that are compatible with async IO
> notifications from things like sockets and files.
>
> This class is a part of rtc_base_approved, so can be used by both
> the webrtc and libjingle parts of the WebRTC library.  Moving forward,
> we can replace rtc::Thread and webrtc::ProcessThread with this implementation.
>
> NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
> run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
> which means that tasks might execute on different threads depending on
> what's the most efficient thing to do.

TBR=perkj@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review-Url: https://codereview.webrtc.org/1935483002
Cr-Commit-Position: refs/heads/master@{#12562}
2016-04-29 13:03:38 +00:00
tommi
0c9df5e568 New task queueing primitive for async tasks: TaskQueue.
TaskQueue is a new way to asynchronously execute tasks sequentially
in a thread safe manner with minimal locking.  The implementation
uses OS supported APIs to do this that are compatible with async IO
notifications from things like sockets and files.

This class is a part of rtc_base_approved, so can be used by both
the webrtc and libjingle parts of the WebRTC library.  Moving forward,
we can replace rtc::Thread and webrtc::ProcessThread with this implementation.

NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
which means that tasks might execute on different threads depending on
what's the most efficient thing to do.

Review-Url: https://codereview.webrtc.org/1919733002
Cr-Commit-Position: refs/heads/master@{#12561}
2016-04-29 11:49:14 +00:00