OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 for (int i = 0; i < 500000; ++i) { | 67 for (int i = 0; i < 500000; ++i) { |
68 SpinLock::Guard guard(lock); | 68 SpinLock::Guard guard(lock); |
69 changeAndCheckBuffer(buffer); | 69 changeAndCheckBuffer(buffer); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 TEST(SpinLockTest, Torture) { | 73 TEST(SpinLockTest, Torture) { |
74 char sharedBuffer[bufferSize]; | 74 char sharedBuffer[bufferSize]; |
75 | 75 |
76 std::unique_ptr<WebThread> thread1 = | 76 std::unique_ptr<WebThread> thread1 = |
77 wrapUnique(Platform::current()->createThread("thread1")); | 77 WTF::wrapUnique(Platform::current()->createThread("thread1")); |
78 std::unique_ptr<WebThread> thread2 = | 78 std::unique_ptr<WebThread> thread2 = |
79 wrapUnique(Platform::current()->createThread("thread2")); | 79 WTF::wrapUnique(Platform::current()->createThread("thread2")); |
80 | 80 |
81 thread1->getWebTaskRunner()->postTask( | 81 thread1->getWebTaskRunner()->postTask( |
82 BLINK_FROM_HERE, | 82 BLINK_FROM_HERE, |
83 crossThreadBind(&threadMain, | 83 crossThreadBind(&threadMain, |
84 crossThreadUnretained(static_cast<char*>(sharedBuffer)))); | 84 crossThreadUnretained(static_cast<char*>(sharedBuffer)))); |
85 thread2->getWebTaskRunner()->postTask( | 85 thread2->getWebTaskRunner()->postTask( |
86 BLINK_FROM_HERE, | 86 BLINK_FROM_HERE, |
87 crossThreadBind(&threadMain, | 87 crossThreadBind(&threadMain, |
88 crossThreadUnretained(static_cast<char*>(sharedBuffer)))); | 88 crossThreadUnretained(static_cast<char*>(sharedBuffer)))); |
89 | 89 |
90 thread1.reset(); | 90 thread1.reset(); |
91 thread2.reset(); | 91 thread2.reset(); |
92 } | 92 } |
93 | 93 |
94 } // namespace blink | 94 } // namespace blink |
OLD | NEW |