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

Side by Side Diff: Source/platform/graphics/filters/ParallelJobs.h

Issue 464273002: Cleanup namespace usage in platform/graphics/[filters/* to skia/*] and platform/graphics/[B-D]* (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 University of Szeged 2 * Copyright (C) 2011 University of Szeged
3 * Copyright (C) 2011 Gabor Loki <loki@webkit.org> 3 * Copyright (C) 2011 Gabor Loki <loki@webkit.org>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 template<typename Type> 57 template<typename Type>
58 class ParallelJobs { 58 class ParallelJobs {
59 WTF_MAKE_NONCOPYABLE(ParallelJobs); 59 WTF_MAKE_NONCOPYABLE(ParallelJobs);
60 WTF_MAKE_FAST_ALLOCATED; 60 WTF_MAKE_FAST_ALLOCATED;
61 public: 61 public:
62 typedef void (*WorkerFunction)(Type*); 62 typedef void (*WorkerFunction)(Type*);
63 63
64 ParallelJobs(WorkerFunction func, size_t requestedJobNumber) 64 ParallelJobs(WorkerFunction func, size_t requestedJobNumber)
65 : m_func(func) 65 : m_func(func)
66 { 66 {
67 size_t numberOfJobs = std::max(static_cast<size_t>(2), std::min(requeste dJobNumber, blink::Platform::current()->numberOfProcessors())); 67 size_t numberOfJobs = std::max(static_cast<size_t>(2), std::min(requeste dJobNumber, Platform::current()->numberOfProcessors()));
68 m_parameters.grow(numberOfJobs); 68 m_parameters.grow(numberOfJobs);
69 // The main thread can execute one job, so only create requestJobNumber - 1 threads. 69 // The main thread can execute one job, so only create requestJobNumber - 1 threads.
70 for (size_t i = 0; i < numberOfJobs - 1; ++i) { 70 for (size_t i = 0; i < numberOfJobs - 1; ++i) {
71 OwnPtr<blink::WebThread> thread = adoptPtr(blink::Platform::current( )->createThread("Unfortunate parallel worker")); 71 OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThrea d("Unfortunate parallel worker"));
72 m_threads.append(thread.release()); 72 m_threads.append(thread.release());
73 } 73 }
74 } 74 }
75 75
76 size_t numberOfJobs() 76 size_t numberOfJobs()
77 { 77 {
78 return m_parameters.size(); 78 return m_parameters.size();
79 } 79 }
80 80
81 Type& parameter(size_t i) 81 Type& parameter(size_t i)
82 { 82 {
83 return m_parameters[i]; 83 return m_parameters[i];
84 } 84 }
85 85
86 void execute() 86 void execute()
87 { 87 {
88 for (size_t i = 0; i < numberOfJobs() - 1; ++i) 88 for (size_t i = 0; i < numberOfJobs() - 1; ++i)
89 m_threads[i]->postTask(new Task(WTF::bind(m_func, &parameter(i)))); 89 m_threads[i]->postTask(new Task(WTF::bind(m_func, &parameter(i))));
90 m_func(&parameter(numberOfJobs() - 1)); 90 m_func(&parameter(numberOfJobs() - 1));
91 m_threads.clear(); 91 m_threads.clear();
92 } 92 }
93 93
94 private: 94 private:
95 WorkerFunction m_func; 95 WorkerFunction m_func;
96 Vector<OwnPtr<blink::WebThread> > m_threads; 96 Vector<OwnPtr<WebThread> > m_threads;
97 Vector<Type> m_parameters; 97 Vector<Type> m_parameters;
98 }; 98 };
99 99
100 } // namespace blink 100 } // namespace blink
101 101
102 #endif // ParallelJobs_h 102 #endif // ParallelJobs_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/filters/FilterOperationsTest.cpp ('k') | Source/platform/graphics/filters/ReferenceFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698