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

feat: IO.TaskState #4097

Merged
merged 3 commits into from
May 11, 2024
Merged

feat: IO.TaskState #4097

merged 3 commits into from
May 11, 2024

Conversation

tydeu
Copy link
Member

@tydeu tydeu commented May 7, 2024

Adds IO.getTaskState which returns the state of a Task in the Lean runtime's task manager. The TaskState inductive has 3 constructors: waiting, running, and finished. The waiting constructor encompasses the waiting and queued states within the C task object documentation, because the task object does not provide a low cost way to distinguish these different forms of waiting. Furthermore, it seems unlikely for consumers to wish to distinguish between these internal states. The running constructor encompasses both the running and promised states in C docs. While not ideal, the C implementation does not provide a way to distinguish between a running Task and a waiting Promise.result (they both have null closures).

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 7, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 7, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 7, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented May 7, 2024

Mathlib CI status (docs):

@tydeu tydeu marked this pull request as ready for review May 7, 2024 21:04
@tydeu tydeu requested a review from Kha May 7, 2024 21:04
Copy link
Member

@Kha Kha left a comment

Choose a reason for hiding this comment

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

Using Promise we could add a test case for at least waiting and finished

inductive TaskState
/--
The `Task` is waiting for dependencies to complete or
sitting in the task manager queue waiting for a thread to run on.
Copy link
Member

Choose a reason for hiding this comment

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

or waiting for Promise.resolve?

Copy link
Member Author

Choose a reason for hiding this comment

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

The docs have been updated. However, after adding the test, I discovered that it is, in fact, the running state that includes the promised C state. Unfortunately, the C implementation does not provide a way to distinguish between a running Task and a waiting Promise.result (they both have null closures). Thus, I added this info to running.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 8, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 8, 2024
@tydeu tydeu added will-merge-soon …unless someone speaks up backport releases/v4.8.0 labels May 8, 2024
@tydeu tydeu added this to the v4.8.0-rc2 milestone May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 8, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request May 10, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request May 10, 2024
@tydeu tydeu added this pull request to the merge queue May 10, 2024
Merged via the queue into leanprover:master with commit 25e94f9 May 11, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request May 11, 2024
Adds `IO.getTaskState` which returns the state of a `Task` in the Lean
runtime's task manager. The `TaskState` inductive has 3 constructors:
`waiting`, `running`, and `finished`. The `waiting` constructor
encompasses the waiting and queued states within the C task object
documentation, because the task object does not provide a low cost way
to distinguish these different forms of waiting. Furthermore, it seems
unlikely for consumers to wish to distinguish between these internal
states. The `running` constructor encompasses both the running and
promised states in C docs. While not ideal, the C implementation does
not provide a way to distinguish between a running `Task` and a waiting
`Promise.result` (they both have null closures).

(cherry picked from commit 25e94f9)
@tydeu tydeu deleted the task-state branch May 12, 2024 14:57
kim-em pushed a commit that referenced this pull request May 12, 2024
Adds `IO.getTaskState` which returns the state of a `Task` in the Lean
runtime's task manager. The `TaskState` inductive has 3 constructors:
`waiting`, `running`, and `finished`. The `waiting` constructor
encompasses the waiting and queued states within the C task object
documentation, because the task object does not provide a low cost way
to distinguish these different forms of waiting. Furthermore, it seems
unlikely for consumers to wish to distinguish between these internal
states. The `running` constructor encompasses both the running and
promised states in C docs. While not ideal, the C implementation does
not provide a way to distinguish between a running `Task` and a waiting
`Promise.result` (they both have null closures).

(cherry picked from commit 25e94f9)
kim-em pushed a commit that referenced this pull request May 21, 2024
Adds `IO.getTaskState` which returns the state of a `Task` in the Lean
runtime's task manager. The `TaskState` inductive has 3 constructors:
`waiting`, `running`, and `finished`. The `waiting` constructor
encompasses the waiting and queued states within the C task object
documentation, because the task object does not provide a low cost way
to distinguish these different forms of waiting. Furthermore, it seems
unlikely for consumers to wish to distinguish between these internal
states. The `running` constructor encompasses both the running and
promised states in C docs. While not ideal, the C implementation does
not provide a way to distinguish between a running `Task` and a waiting
`Promise.result` (they both have null closures).

(cherry picked from commit 25e94f9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport releases/v4.8.0 builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN will-merge-soon …unless someone speaks up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants