Skip to content

Commit 979605d

Browse files
snarkmasterfacebook-github-bot
authored andcommitted
Add SafeTask::asUnsafe() deprecated escape hatch
Reviewed By: ispeters Differential Revision: D77846650 fbshipit-source-id: fd08fe3dbb17b34d8e911f1fb04f26796b1092e3
1 parent df34009 commit 979605d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

third-party/folly/src/folly/coro/safe/SafeTask.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,16 @@ class FOLLY_NODISCARD SafeTaskWithExecutor final
333333

334334
public:
335335
using folly_private_safe_alias_t = safe_alias_constant<ArgSafety>;
336+
337+
[[deprecated(
338+
"`asUnsafe()` is an provided as escape hatch for interoperating with "
339+
"older futures-based code, or other places not yet compatible with "
340+
"true structured concurrency patterns. Beware, the full `Task` API "
341+
"abounds with footguns like `start()` and `semi()` -- including UB, "
342+
"leaks, and lost errors.")]]
343+
TaskWithExecutor<T> asUnsafe() && {
344+
return std::move(*this).unwrapTaskWithExecutor();
345+
}
336346
};
337347

338348
template <safe_alias ArgSafety, typename T>
@@ -359,6 +369,16 @@ class FOLLY_CORO_TASK_ATTRS SafeTask final
359369
public:
360370
using detail::SafeTaskBaseTraits<ArgSafety, T>::type::type;
361371
using folly_private_safe_alias_t = safe_alias_constant<ArgSafety>;
372+
373+
[[deprecated(
374+
"`asUnsafe()` is an provided as escape hatch for interoperating with "
375+
"older futures-based code, or other places not yet compatible with "
376+
"true structured concurrency patterns. Beware, the full `Task` API "
377+
"abounds with footguns like `start()` and `semi()` -- including UB, "
378+
"leaks, and lost errors.")]]
379+
Task<T> asUnsafe() && {
380+
return std::move(*this).unwrapTask();
381+
}
362382
};
363383

364384
template <safe_alias Safety, typename T>

0 commit comments

Comments
 (0)