OLD | NEW |
1 // Copyright (c) 2007, Google Inc. | 1 // Copyright (c) 2007, Google Inc. |
2 // All rights reserved. | 2 // 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 #endif /* HAVE_SYS_RESOURCE_H */ | 74 #endif /* HAVE_SYS_RESOURCE_H */ |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 struct FunctionAndId { | 78 struct FunctionAndId { |
79 void (*ptr_to_function)(int); | 79 void (*ptr_to_function)(int); |
80 int id; | 80 int id; |
81 }; | 81 }; |
82 | 82 |
83 #if defined(NO_THREADS) || !(defined(HAVE_PTHREADS) || defined(_WIN32)) | 83 #if defined(NO_THREADS) || !(defined(HAVE_PTHREAD) || defined(_WIN32)) |
84 | 84 |
85 extern "C" void RunThread(void (*fn)()) { | 85 extern "C" void RunThread(void (*fn)()) { |
86 (*fn)(); | 86 (*fn)(); |
87 } | 87 } |
88 | 88 |
89 extern "C" void RunManyThreads(void (*fn)(), int count) { | 89 extern "C" void RunManyThreads(void (*fn)(), int count) { |
90 // I guess the best we can do is run fn sequentially, 'count' times | 90 // I guess the best we can do is run fn sequentially, 'count' times |
91 for (int i = 0; i < count; i++) | 91 for (int i = 0; i < count; i++) |
92 (*fn)(); | 92 (*fn)(); |
93 } | 93 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 SAFE_PTHREAD(pthread_join(thr[i], NULL)); | 214 SAFE_PTHREAD(pthread_join(thr[i], NULL)); |
215 } | 215 } |
216 delete[] fn_and_ids; | 216 delete[] fn_and_ids; |
217 delete[] thr; | 217 delete[] thr; |
218 | 218 |
219 pthread_attr_destroy(&attr); | 219 pthread_attr_destroy(&attr); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 #endif | 223 #endif |
OLD | NEW |