Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@achabense
Copy link
Contributor

@achabense achabense commented Aug 9, 2023

  • replaces long trailing decltype return types with decltype(auto) in several places
  • removes some redundant _Packaged_state constructors
  • simplifies signatures of _Packaged_state::_Get_fn, and remove an extra copy construction around it
  • makes some usings private in packaged_task
  • removes some uncommon forward patterns

@achabense achabense requested a review from a team as a code owner August 9, 2023 13:18
@achabense achabense changed the title <future> cleanups <future> cleanups Aug 9, 2023
_Packaged_state(const _Fty2& _Fnarg, const _Alloc& _Al, _Mydel* _Dp)
: _Mybase(_Dp), _Fn(allocator_arg, _Al, _Fnarg) {}
#endif // _HAS_FUNCTION_ALLOCATOR_SUPPORT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are fully replaceable with their _Fty2&& versions

_MyStateType* _MyState = static_cast<_MyStateType*>(_State._Ptr());
function<_Ret(_ArgTypes...)> _Fnarg = _MyState->_Get_fn();
_MyPromiseType _New_promise(new _MyStateType(_Fnarg));
_MyPromiseType _New_promise(new _MyStateType(_MyState->_Get_fn()));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 80% sure about this change; or was the extra copy construction intentional here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it was intentional.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Aug 9, 2023
@StephanTLavavej
Copy link
Member

Can you please provide PR descriptions so that reviewers, and future code archaeologists, can quickly understand what is being changed and why? Only for something completely trivial like "Fix comment typos" is a PR title sufficient.

@StephanTLavavej StephanTLavavej self-assigned this Aug 9, 2023
@achabense
Copy link
Contributor Author

achabense commented Aug 10, 2023

Hmm, added.

@frederick-vs-ja
Copy link
Contributor

// update, so this adapter turns copies into terminate(). When VSO-153581 is

Now we should say abort() instead. Should we change the comment in this PR or file a "good first issue"?

@StephanTLavavej
Copy link
Member

I'm in favor of just fixing the comment here. "Good first issues" are a bit more work for the maintainers and we don't have a lot of capacity right now.

@achabense
Copy link
Contributor Author

achabense commented Sep 4, 2023

I think the usage of forward looks strange here. Can we replace it with move or static_cast<_Mybase&&>? (also at line 988 and 1015)

STL/stl/inc/future

Lines 962 to 963 in 6c69a73

shared_future(future<_Ty>&& _Other) noexcept : _Mybase(_STD forward<_Mybase>(_Other)) {}

@CaseyCarter
Copy link
Contributor

I think the usage of forward looks strange here. Can we replace it with move or static_cast<_Mybase&&>?

I'm not bothered by this usage of forward because I've heard Howard Hinnant describe why it's an intended usage. That said, it certainly never caught on and I don't consider it idiomatic. I would much rather have static_cast<_Mybase&&> here than std::move if we're going to make a change: I like it explicit that there's something weird happening here.

[[noreturn]] _Fake_no_copy_callable_adapter(const _Fake_no_copy_callable_adapter& _Other)
: _Storage(_STD move(_Other._Storage)) {
_CSTD abort(); // shouldn't be called, see GH-3888
_CSTD abort(); // shouldn't be called
Copy link
Contributor Author

@achabense achabense Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( I begin to feel "see GH-3888" a bit awkward, as the reason has been explained at the beginning of the class :| )

_MyStateType* _MyState = static_cast<_MyStateType*>(_State._Ptr());
function<_Ret(_ArgTypes...)> _Fnarg = _MyState->_Get_fn();
_MyPromiseType _New_promise(new _MyStateType(_Fnarg));
_MyPromiseType _New_promise(new _MyStateType(_MyState->_Get_fn()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it was intentional.

Comment on lines -1394 to +1367
auto _Invoke_stored(tuple<_Types...>&& _Tuple)
-> decltype(_Invoke_stored_explicit(_STD move(_Tuple), index_sequence_for<_Types...>{})) { // invoke() a tuple
decltype(auto) _Invoke_stored(tuple<_Types...>&& _Tuple) { // invoke() a tuple
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change requested: The difference here is that decltype(auto) won't SFINAE, but it appears that we don't need SFINAE here (nothing can directly ask is_invocable).

@StephanTLavavej StephanTLavavej removed their assignment Sep 15, 2023
@StephanTLavavej
Copy link
Member

I think we can merge this without a second maintainer approval.

@StephanTLavavej StephanTLavavej self-assigned this Sep 20, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 4f97dbb into microsoft:main Sep 21, 2023
@StephanTLavavej
Copy link
Member

⏳ ⏱️ 🧹

@achabense achabense deleted the _Future_cleanups branch September 22, 2023 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants