Browse Source

process: refine then return type

skypjack 8 months ago
parent
commit
33b1daafa0
2 changed files with 6 additions and 2 deletions
  1. 3 1
      src/entt/process/process.hpp
  2. 3 1
      test/entt/process/process.cpp

+ 3 - 1
src/entt/process/process.hpp

@@ -183,9 +183,11 @@ public:
     /**
     /**
      * @brief Assigns a child process to run in case of success.
      * @brief Assigns a child process to run in case of success.
      * @param child A child process to run in case of success.
      * @param child A child process to run in case of success.
+     * @return The newly assigned child process.
      */
      */
-    void then(std::shared_ptr<basic_process> child) {
+    basic_process& then(std::shared_ptr<basic_process> child) {
         next = std::move(child);
         next = std::move(child);
+        return *next;
     }
     }
 
 
     /**
     /**

+ 3 - 1
test/entt/process/process.cpp

@@ -190,9 +190,11 @@ TEST(ProcessAdaptor, ThenPeek) {
 
 
     ASSERT_FALSE(process.peek());
     ASSERT_FALSE(process.peek());
 
 
-    process.then(std::make_shared<test_process<int>>());
+    process.then(std::make_shared<test_process<int>>()).then(std::make_shared<test_process<int>>());
 
 
     ASSERT_TRUE(process.peek());
     ASSERT_TRUE(process.peek());
+    ASSERT_TRUE(process.peek()->peek());
+    ASSERT_FALSE(process.peek()->peek()->peek());
     // peek does not release ownership
     // peek does not release ownership
     ASSERT_TRUE(process.peek());
     ASSERT_TRUE(process.peek());
 }
 }