Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::task - Revamp TaskBuilder API #14989

Closed
wants to merge 2 commits into from
Closed

Conversation

aturon
Copy link
Member

@aturon aturon commented Jun 17, 2014

This patch consolidates and cleans up the task spawning APIs:

  • Removes the problematic future_result method from std::task::TaskBuilder,
    and adds a try_future that both spawns the task and returns a future
    representing its eventual result (or failure).
  • Removes the public opts field from TaskBuilder, instead adding appropriate
    builder methods to configure the task.
  • Adds extension traits to libgreen and libnative that add methods to
    TaskBuilder for spawning the task as a green or native thread.

Previously, there was no way to benefit from the TaskBuilder functionality and
also set the scheduler to spawn within.

With this change, all task spawning scenarios are supported through the
TaskBuilder interface.

Closes #3725.

[breaking-change]

@aturon
Copy link
Member Author

aturon commented Jun 18, 2014

@huonw Thanks for the numerous good suggestions (which github seems to've dropped completely after a force-push? I thought it kept the old comments around... Am I doing something wrong here??)

I've implemented nearly all of your suggestions, with two exceptions:

  • I left with_wrapper intact. I had considered deprecating or taking it out, but I'd rather save that for a library stabilization pass.
  • I did not add experimental markings, since I think the feature gate on default type parameters suffices.

@huonw
Copy link
Member

huonw commented Jun 18, 2014

(which github seems to've dropped completely after a force-push? I thought it kept the old comments around... Am I doing something wrong here??)

Oh oops, my fault. I must've commented on the commit directly, not the PR-wide "files changed" view (I try to avoid doing that for exactly this reason). Commit comments are dropped with a force push, but comments on that view just become "outdated ...". You can get the old comments if you have the old hash of that commit (via https://github.com/aturon/rust/commit/$hash), or, I guess, via the emails/notifications github gave you for my comments).

Those two exceptions sound fine to me.

});
assert_eq!(res.ok().unwrap(), "Success!".to_string());
pool.shutdown();
}
Copy link
Member

Choose a reason for hiding this comment

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

This is so slick, I wonder if the SchedPool api should be scaled back...

aturon added 2 commits June 18, 2014 10:42
This patch consolidates and cleans up the task spawning APIs:

* Removes the problematic `future_result` method from `std::task::TaskBuilder`,
  and adds a `try_future` that both spawns the task and returns a future
  representing its eventual result (or failure).

* Removes the public `opts` field from `TaskBuilder`, instead adding appropriate
  builder methods to configure the task.

* Adds extension traits to libgreen and libnative that add methods to
  `TaskBuilder` for spawning the task as a green or native thread.

Previously, there was no way to benefit from the `TaskBuilder` functionality and
also set the scheduler to spawn within.

With this change, all task spawning scenarios are supported through the
`TaskBuilder` interface.

Closes rust-lang#3725.

[breaking-change]
This commit brings code downstream of libstd up to date with the new
TaskBuilder API.
@aturon
Copy link
Member Author

aturon commented Jun 18, 2014

@alexcrichton I've addressed all of your comments.

@brson
Copy link
Contributor

brson commented Jun 18, 2014

This looks great. @aturon do you have confidence that sync::future is going to improve enough that we don't have to deprecate it?

@aturon
Copy link
Member Author

aturon commented Jun 18, 2014

@brson Yes, I plan on improving sync::future in the near term. That's part of a plan to lay out a consistent set of "cell-like" data structures varying along several axes (immutable, monotonic, mutable, thread-local, atomic).

That effort is separate from the post 1.0 goal of a comprehensive async IO API, which might also involve a futures-like construct (but likely as a separate and more general notion of "Event").

lnicola pushed a commit to lnicola/rust that referenced this pull request Jun 19, 2023
…anic, r=Veykril

fix: derive source scope from syntax node to be transformed

Fixes rust-lang#14534

When we use `PathTransform` for associated items of a trait, we have been feeding `SemanticsScope` for the trait definition to it as source scope. `PathTransform` uses the source scope to resolve paths in associated items to find which path to transform. In the course of path resolution, the scope is responsible for lowering `ast::MacroType`s (because they can be written within a path) using `AstIdMap` for the scope's `HirFileId`.

The problem here is that when an associated item is generated by a macro, the scope for the trait is different from the scope for that associated item. The former can only resolve the top-level macros within the trait definition but not the macro calls generated by those top-level macros. We need the latter to resolve such nested macros.

This PR makes sure that we pass `SemanticsScope` for each associated item we're applying path transformation to.
lnicola pushed a commit to lnicola/rust that referenced this pull request Jun 19, 2023
…anic, r=lnicola

minor: remove commented out conflicts

Follow-up to rust-lang#14989 🤦‍♂️
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change how task::future_result works
4 participants