Sleep in ThreadTest thread functions.
Prevents busy loops that really mess up Valgrind's thread scheduling, this brings runtimes from up to minutes down to milliseconds. BUG= R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/13969004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6728 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d1ea06b3d5
commit
e9e4253a3c
@ -12,11 +12,13 @@
|
|||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||||
|
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Function that does nothing, and reports success.
|
// Function that does nothing, and reports success.
|
||||||
bool NullRunFunction(void* obj) {
|
bool NullRunFunction(void* obj) {
|
||||||
|
SleepMs(0); // Hand over timeslice, prevents busy looping.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ TEST(ThreadTest, StartStop) {
|
|||||||
bool SetFlagRunFunction(void* obj) {
|
bool SetFlagRunFunction(void* obj) {
|
||||||
bool* obj_as_bool = static_cast<bool*>(obj);
|
bool* obj_as_bool = static_cast<bool*>(obj);
|
||||||
*obj_as_bool = true;
|
*obj_as_bool = true;
|
||||||
|
SleepMs(0); // Hand over timeslice, prevents busy looping.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user