Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Side by Side Diff: ppapi/tests/test_post_message.cc

Issue 547543002: Fix potential race-condition _beginthread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed typedef PP_WindowsThreadFunction. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« ppapi/tests/pp_thread.h ('K') | « ppapi/tests/test_case.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/tests/test_post_message.h" 5 #include "ppapi/tests/test_post_message.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <sstream> 10 #include <sstream>
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 WaitForMessages(); 862 WaitForMessages();
863 ASSERT_TRUE(ClearListeners()); 863 ASSERT_TRUE(ClearListeners());
864 ASSERT_TRUE(AddEchoingListener("message_event.data")); 864 ASSERT_TRUE(AddEchoingListener("message_event.data"));
865 message_data_.clear(); 865 message_data_.clear();
866 866
867 // Set up a thread for each integer from 0 to (kThreadsToRun - 1). Make each 867 // Set up a thread for each integer from 0 to (kThreadsToRun - 1). Make each
868 // thread send the number that matches its index kMessagesToSendPerThread 868 // thread send the number that matches its index kMessagesToSendPerThread
869 // times. For good measure, call postMessage from the main thread 869 // times. For good measure, call postMessage from the main thread
870 // kMessagesToSendPerThread times. At the end, we make sure we got all the 870 // kMessagesToSendPerThread times. At the end, we make sure we got all the
871 // values we expected. 871 // values we expected.
872 PP_ThreadType threads[kThreadsToRun]; 872 PP_Thread threads[kThreadsToRun];
873 for (int32_t i = 0; i < kThreadsToRun; ++i) { 873 for (int32_t i = 0; i < kThreadsToRun; ++i) {
874 // Set up a thread to send a value of i. 874 // Set up a thread to send a value of i.
875 void* arg = new InvokePostMessageThreadArg(instance_, pp::Var(i)); 875 void* arg = new InvokePostMessageThreadArg(instance_, pp::Var(i));
876 PP_CreateThread(&threads[i], &InvokePostMessageThreadFunc, arg); 876 PP_CreateThread(&threads[i], &InvokePostMessageThreadFunc, arg);
877 } 877 }
878 // Invoke PostMessage right now to send a value of (kThreadsToRun). 878 // Invoke PostMessage right now to send a value of (kThreadsToRun).
879 for (int32_t i = 0; i < kMessagesToSendPerThread; ++i) 879 for (int32_t i = 0; i < kMessagesToSendPerThread; ++i)
880 instance_->PostMessage(pp::Var(kThreadsToRun)); 880 instance_->PostMessage(pp::Var(kThreadsToRun));
881 881
882 // Now join all threads. 882 // Now join all threads.
(...skipping 26 matching lines...) Expand all
909 ASSERT_TRUE(received_value <= kThreadsToRun); 909 ASSERT_TRUE(received_value <= kThreadsToRun);
910 ++received_counts[received_value]; 910 ++received_counts[received_value];
911 } 911 }
912 ASSERT_EQ(expected_counts, received_counts); 912 ASSERT_EQ(expected_counts, received_counts);
913 913
914 message_data_.clear(); 914 message_data_.clear();
915 ASSERT_TRUE(ClearListeners()); 915 ASSERT_TRUE(ClearListeners());
916 916
917 PASS(); 917 PASS();
918 } 918 }
OLDNEW
« ppapi/tests/pp_thread.h ('K') | « ppapi/tests/test_case.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698