| 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(g_lock); | 68 SpinLock::Guard guard(g_lock); |
| 69 ChangeAndCheckBuffer(buffer); | 69 ChangeAndCheckBuffer(buffer); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 TEST(SpinLockTest, Torture) { | 73 TEST(SpinLockTest, Torture) { |
| 74 char shared_buffer[kBufferSize]; | 74 char shared_buffer[kBufferSize]; |
| 75 | 75 |
| 76 std::unique_ptr<WebThread> thread1 = | 76 std::unique_ptr<WebThread> thread1 = |
| 77 Platform::Current()->CreateThread("thread1"); | 77 WTF::WrapUnique(Platform::Current()->CreateThread("thread1")); |
| 78 std::unique_ptr<WebThread> thread2 = | 78 std::unique_ptr<WebThread> thread2 = |
| 79 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, CrossThreadUnretained( | 83 CrossThreadBind(&ThreadMain, CrossThreadUnretained( |
| 84 static_cast<char*>(shared_buffer)))); | 84 static_cast<char*>(shared_buffer)))); |
| 85 thread2->GetWebTaskRunner()->PostTask( | 85 thread2->GetWebTaskRunner()->PostTask( |
| 86 BLINK_FROM_HERE, | 86 BLINK_FROM_HERE, |
| 87 CrossThreadBind(&ThreadMain, CrossThreadUnretained( | 87 CrossThreadBind(&ThreadMain, CrossThreadUnretained( |
| 88 static_cast<char*>(shared_buffer)))); | 88 static_cast<char*>(shared_buffer)))); |
| 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 |