feat support chain operator
All checks were successful
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 46s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 8m7s

This commit is contained in:
tqcq 2024-03-15 11:40:49 +08:00
parent f794cb500a
commit 3bcd014992

View File

@ -5,6 +5,7 @@
**/ **/
#pragma once #pragma once
#include "sled/make_ref_counted.h"
#ifndef SLED_OPERATIONS_CHAIN_H #ifndef SLED_OPERATIONS_CHAIN_H
#define SLED_OPERATIONS_CHAIN_H #define SLED_OPERATIONS_CHAIN_H
@ -60,12 +61,14 @@ public:
bool IsEmpty() const; bool IsEmpty() const;
template<typename FunctorT> template<typename FunctorT>
void ChainOperation(FunctorT &&functor) scoped_refptr<OperationsChain> ChainOperation(FunctorT &&functor)
{ {
auto wrapper = new internal::OperationWithFunctor<FunctorT>(std::forward<FunctorT>(functor), CreateOpeartionsChainCallback()); auto wrapper = new internal::OperationWithFunctor<FunctorT>(std::forward<FunctorT>(functor),
CreateOpeartionsChainCallback());
chained_operations_.push(std::unique_ptr<internal::OperationWithFunctor<FunctorT>>(wrapper)); chained_operations_.push(std::unique_ptr<internal::OperationWithFunctor<FunctorT>>(wrapper));
if (chained_operations_.size() == 1) { chained_operations_.front()->Run(); } if (chained_operations_.size() == 1) { chained_operations_.front()->Run(); }
return scoped_refptr<OperationsChain>(this);
} }
private: private: