MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ForEach

Function ForEach

tensorflow/core/platform/file_system_helper.cc:39–51  ·  view source on GitHub ↗

Run a function in parallel using a ThreadPool, but skip the ThreadPool on the iOS platform due to its problems with more than a few threads.

Source from the content-addressed store, hash-verified

37// Run a function in parallel using a ThreadPool, but skip the ThreadPool
38// on the iOS platform due to its problems with more than a few threads.
39void ForEach(int first, int last, const std::function<void(int)>& f) {
40#if TARGET_OS_IPHONE
41 for (int i = first; i < last; i++) {
42 f(i);
43 }
44#else
45 int num_threads = std::min(kNumThreads, last - first);
46 thread::ThreadPool threads(Env::Default(), "ForEach", num_threads);
47 for (int i = first; i < last; i++) {
48 threads.Schedule([f, i] { f(i); });
49 }
50#endif
51}
52
53} // namespace
54

Callers 1

GetMatchingPathsFunction · 0.85

Calls 4

DefaultFunction · 0.85
fFunction · 0.50
minFunction · 0.50
ScheduleMethod · 0.45

Tested by

no test coverage detected