Squashed 'third_party/marl/' changes from 7b43abfc4..f936d9438

f936d9438 Allow Affinity to be constructed from a vector. (#210)

git-subtree-dir: third_party/marl
git-subtree-split: f936d9438b2b0d92512075ea4dd5e0d47f80094a
diff --git a/include/marl/thread.h b/include/marl/thread.h
index 68434cb..1fb2436 100644
--- a/include/marl/thread.h
+++ b/include/marl/thread.h
@@ -99,6 +99,9 @@
 
     MARL_EXPORT Affinity(std::initializer_list<Core>, Allocator* allocator);
 
+    MARL_EXPORT Affinity(const containers::vector<Core, 32>&,
+                         Allocator* allocator);
+
     // count() returns the number of enabled cores in the affinity.
     MARL_EXPORT size_t count() const;
 
diff --git a/src/thread.cpp b/src/thread.cpp
index d0750fa..30897f0 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -129,6 +129,10 @@
   }
 }
 
+Thread::Affinity::Affinity(const containers::vector<Core, 32>& coreList,
+                           Allocator* allocator)
+    : cores(coreList, allocator) {}
+
 Thread::Affinity Thread::Affinity::all(
     Allocator* allocator /* = Allocator::Default */) {
   Thread::Affinity affinity(allocator);
diff --git a/src/thread_test.cpp b/src/thread_test.cpp
index 69370f9..306a959 100644
--- a/src/thread_test.cpp
+++ b/src/thread_test.cpp
@@ -100,6 +100,20 @@
   }
 }
 
+TEST_F(WithoutBoundScheduler, ThreadAffinityFromVector) {
+  marl::containers::vector<marl::Thread::Core, 32> cores(allocator);
+  cores.push_back(core(10));
+  cores.push_back(core(20));
+  cores.push_back(core(30));
+  cores.push_back(core(40));
+  auto affinity = marl::Thread::Affinity(cores, allocator);
+  EXPECT_EQ(affinity.count(), cores.size());
+  EXPECT_EQ(affinity[0], core(10));
+  EXPECT_EQ(affinity[1], core(20));
+  EXPECT_EQ(affinity[2], core(30));
+  EXPECT_EQ(affinity[3], core(40));
+}
+
 TEST_F(WithoutBoundScheduler, ThreadAffinityPolicyOneOf) {
   auto all = marl::Thread::Affinity(
       {