Skip to content

Commit

Permalink
Pass FunctionPtd params by const ref
Browse files Browse the repository at this point in the history
  • Loading branch information
lganzzzo committed Sep 15, 2019
1 parent 133b79f commit 8c1a367
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/oatpp/core/async/Coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Action::Action(AbstractCoroutine* coroutine)
m_data.coroutine = coroutine;
}

Action::Action(FunctionPtr functionPtr)
Action::Action(const FunctionPtr& functionPtr)
: m_type(TYPE_YIELD_TO)
{
m_data.fptr = functionPtr;
Expand Down
14 changes: 7 additions & 7 deletions src/oatpp/core/async/Coroutine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Action {
* Constructor. Create yield_to Action.
* @param functionPtr - pointer to function.
*/
Action(FunctionPtr functionPtr);
Action(const FunctionPtr& functionPtr);

/**
* Deleted copy-constructor.
Expand Down Expand Up @@ -401,7 +401,7 @@ class CoroutineHandle : public oatpp::base::Countable {
CoroutineHandle(Processor* processor, AbstractCoroutine* rootCoroutine);

~CoroutineHandle();

Action iterate();

bool finished() const;
Expand Down Expand Up @@ -485,7 +485,7 @@ class AbstractCoroutine : public oatpp::base::Countable {
* @param ptr - pointer of the function to call.
* @return - Action.
*/
virtual Action call(FunctionPtr ptr) = 0;
virtual Action call(const FunctionPtr& ptr) = 0;

/**
* Default implementation of handleError(error) function.
Expand Down Expand Up @@ -568,7 +568,7 @@ class Coroutine : public AbstractCoroutine {
* @param ptr - pointer of the function to call.
* @return - Action.
*/
Action call(FunctionPtr ptr) override {
Action call(const FunctionPtr& ptr) override {
Function f = static_cast<Function>(ptr);
return (static_cast<T*>(this)->*f)();
}
Expand All @@ -578,7 +578,7 @@ class Coroutine : public AbstractCoroutine {
* @param function - pointer to function.
* @return - yield Action.
*/
Action yieldTo(Function function) const {
Action yieldTo(const Function& function) const {
return Action(static_cast<FunctionPtr>(function));
}

Expand Down Expand Up @@ -755,7 +755,7 @@ class CoroutineWithResult : public AbstractCoroutineWithResult<Args...> {
* @param ptr - pointer of the function to call.
* @return - Action.
*/
virtual Action call(AbstractCoroutine::FunctionPtr ptr) override {
virtual Action call(const AbstractCoroutine::FunctionPtr& ptr) override {
Function f = static_cast<Function>(ptr);
return (static_cast<T*>(this)->*f)();
}
Expand All @@ -765,7 +765,7 @@ class CoroutineWithResult : public AbstractCoroutineWithResult<Args...> {
* @param function - pointer to function.
* @return - yield Action.
*/
Action yieldTo(Function function) const {
Action yieldTo(const Function& function) const {
return Action(static_cast<AbstractCoroutine::FunctionPtr>(function));
}

Expand Down

0 comments on commit 8c1a367

Please sign in to comment.