proxygen
Parallel.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 #define FOLLY_GEN_PARALLEL_H_
19 
20 #include <mutex>
21 
22 #include <folly/gen/Base.h>
23 
24 namespace folly {
25 namespace gen {
26 namespace detail {
27 
28 template <class Ops>
29 class Parallel;
30 
31 template <class Sink>
32 class Sub;
33 
34 template <class Iterator>
35 class ChunkedRangeSource;
36 
37 } // namespace detail
38 
45 template <
46  class Container,
47  class Iterator = typename Container::const_iterator,
48  class Chunked = detail::ChunkedRangeSource<Iterator>>
49 Chunked chunked(const Container& container, int chunkSize = 256) {
50  return Chunked(chunkSize, folly::range(container.begin(), container.end()));
51 }
52 
53 template <
54  class Container,
55  class Iterator = typename Container::iterator,
57 Chunked chunked(Container& container, int chunkSize = 256) {
58  return Chunked(chunkSize, folly::range(container.begin(), container.end()));
59 }
60 
87 template <class Ops, class Parallel = detail::Parallel<Ops>>
88 Parallel parallel(Ops ops, size_t threads = 0) {
89  return Parallel(std::move(ops), threads);
90 }
91 
103 template <class Sink, class Sub = detail::Sub<Sink>>
104 Sub sub(Sink sink) {
105  return Sub(std::move(sink));
106 }
107 } // namespace gen
108 } // namespace folly
109 
110 #include <folly/gen/Parallel-inl.h>
Sub sub(Sink sink)
Definition: Parallel.h:104
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
std::vector< std::thread::id > threads
void Sub(size_t iterations, ValueT kMin, ValueT kMax)
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
const int ops
Parallel parallel(Ops ops, size_t threads=0)
Definition: Parallel.h:88
Chunked chunked(const Container &container, int chunkSize=256)
Definition: Parallel.h:49