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

Specify initial data #67

Merged
merged 1 commit into from
Jul 6, 2016
Merged

Specify initial data #67

merged 1 commit into from
Jul 6, 2016

Conversation

therustmonk
Copy link
Contributor

Initial data on fisrt resuming is unsound and lost. It's important to take any piece data of resume send.

This PR fixes it, and makes possible to take value of first resume call.

It breaks backward compatibility, but not terrible.

@zonyitoo What's your opinion?

@zonyitoo
Copy link
Contributor

zonyitoo commented Jul 6, 2016

Huh... why you need that? The closure itself can capture any initial data you want.

@therustmonk
Copy link
Contributor Author

I send some fat data by pointer and restore it inside coroutine. But if I can't take first value, data will lost. I must to unpack it to prevent memory leaks, because use Box::into_raw().

Also I can't use one method and have to use two different like: resume_first() and resume_with(data) to resuming. I use array of Handles where coroutines can be in different states and I have to track order of resuming to use different methods. This adds unwanted overhead.

My coroutines are generic and created dynamically by user's code, that's why I need to send initial data sometimes.

@zonyitoo
Copy link
Contributor

zonyitoo commented Jul 6, 2016

Hmm, sounds reasonable.
It just quite a little breaking change, which is very easy to modify. Merge it right now.

@zonyitoo zonyitoo merged commit dc97af8 into rustcc:master Jul 6, 2016
@therustmonk
Copy link
Contributor Author

@zonyitoo I've checked it with my project, works fine! Thank you!

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.

2 participants