Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/FunctionGuard.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FunctionGuard
{
public:
FunctionGuard() = default; /// Default constructor
FunctionGuard(nullptr_t) /// Null-pointer constructor
FunctionGuard(std::nullptr_t) /// Null-pointer constructor
{
}
FunctionGuard(tFn in_fn) /// Functor constructor
Expand All @@ -80,7 +80,7 @@ class FunctionGuard
in_other.Forget();
return *this;
}
FunctionGuard& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor)
FunctionGuard& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor)
{
Forget();
return *this;
Expand Down
6 changes: 6 additions & 0 deletions include/Private/TasksCommonPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ NAMESPACE_SQUID_END
#define COROUTINE_OPTIMIZE_ON _Pragma("clang optimize on")
#endif

#if defined(__clang__)
#define SQUID_FORCENOINLINE __attribute__((noinline))
#else
#define SQUID_FORCENOINLINE
#endif

// False type for use in static_assert() [static_assert(false, ...) -> static_assert(static_false<T>, ...)]
#include <type_traits>
template<typename T>
Expand Down
7 changes: 5 additions & 2 deletions include/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// @defgroup Awaiters Awaiters
/// @brief Versatile task awaiters that offer utility to most projects

#include <algorithm>
#include <functional>
#include <future>
#include <memory>
Expand Down Expand Up @@ -216,14 +217,16 @@ class Task
Task() /// Default constructor (constructs an invalid handle)
{
}
Task(nullptr_t) /// Null-pointer constructor (constructs an invalid handle)
Task(std::nullptr_t) /// Null-pointer constructor (constructs an invalid handle)
{
}
Task(std::shared_ptr<tTaskInternal> in_taskInternal) /// @private
: m_taskInternal(in_taskInternal)
{
AddRef();
}
// Heap elision crash on clang https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0981r0.html
SQUID_FORCENOINLINE
Task(std::coroutine_handle<promise_type> in_coroHandle) /// @private
: m_taskInternal(std::make_shared<tTaskInternal>(in_coroHandle))
{
Expand All @@ -240,7 +243,7 @@ class Task
{
// NOTE: No need to alter logical reference here (this is a move)
}
Task& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid)
Task& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid)
{
RemoveRef(); // Remove logical reference from old internal task
m_taskInternal = nullptr;
Expand Down