proxygen
PriorityLifoSemMPMCQueueTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017-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 #include <vector>
18 
19 #include <folly/Range.h>
23 
24 using namespace folly;
25 
27  const std::vector<size_t> capacities = {1, 2, 3};
29  folly::range(capacities));
30 
31  for (auto capacity : folly::enumerate(capacities)) {
32  auto pri = static_cast<int8_t>(capacity.index) - 1;
33  for (size_t i = 0; i < *capacity; ++i) {
34  EXPECT_NO_THROW(q.addWithPriority(0, pri)) << *capacity << " " << i;
35  }
36  EXPECT_THROW(q.addWithPriority(0, pri), QueueFullException) << *capacity;
37  }
38 }
#define EXPECT_NO_THROW(statement)
Definition: gtest.h:1845
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
detail::RangeEnumerator< Range > enumerate(Range &&r)
Definition: Enumerate.h:167
BlockingQueueAddResult addWithPriority(T item, int8_t priority) override
TEST(SequencedExecutor, CPUThreadPoolExecutor)