-
Notifications
You must be signed in to change notification settings - Fork 149
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
Code documentation: task scheduling #37
Comments
Thank you for the feedback! Perhaps it'd be useful to define somewhere what words mean, i.e. what is a 'task' and 'future', or what does 'schedule' and 'wake' mean. Is this a useful comment to you, did you find it (perhaps it was not easy to find)? |
Ah, I don't believe I looked that closely at that comment. My tunnel vision here was to look really hard at the That comment is pretty helpful. I think that I didn't really understand what Maybe additionally having something like Perhaps in this case, it's not even about better definitions, but about providing breadcrumbs to the connections. While your comment definitely helps with my deeper understanding of And perhaps it's also just a case of me having an incorrect model which made it hard for me to see what's in front of me. :) So, it may be good to wait and see if others have the same issue I do before deciding whether to do anything. |
I see, thank you for the elaborate explanation of your thought process :) I can try to improve the comments later, but if you'd like to help and add them yourself, go ahead! I believe you could even just click "edit" on GitHub, add more comments, and submit a PR. |
I think this issue might be appropriate, as smol is also intended as a project to help people learn about async executors.
Overall, I found the code very easy to follow (thanks @stjepang !). The one place I was completely confused was how/where there was differentiation between awake and asleep tasks.
I finally semi-randomly read the docs for
async_task::Task
and realized that after running a task, itsTask
ref will be gone ifPoll::Pending
, but theschedule
function would take a reference to an awoken task and reschedule it somehow. https://docs.rs/async-task/3.0.0/async_task/struct.Task.html . As soon as I read it I knew what was going on, but since I wasn't familiar with it beforehand it took a while to find this information.I think I was confused because I expected the scheduling to be handled from the executor side, instead of the task side, if that makes any sense. (i.e. I was trying to figure out the queue in the executor where the asleep tasks were kept).
Anyways, I now understand that the
schedule
closure at https://github.com/stjepang/smol/blob/master/src/thread_local.rs#L81 is meant for rescheduling woken up tasks, and not just on the initial spawn. I guess to meschedules a runnable task
was not enough information there, since I've been thinking in terms ofwaking
.Perhaps someone else would not have gotten stuck here, but I just wanted to share my experience in case it helps somebody else navigate the code.
Let me know if this feedback is helpful, and if it would be helpful for me to try to clarify in the code comments.
The text was updated successfully, but these errors were encountered: