Closed lgxbslgx closed 5 days ago
git diff
OutputPotential Synchronization Issue with Arc::clone
:
Arc::clone(&printed)
to clone an Arc
reference. Ensure that the printed
variable is properly synchronized across threads if it is being accessed concurrently. This is not a direct error but a potential concern for thread safety.Inconsistent Formatting in async move
Block:
trace::scope("test", || async { ... })
block, which was formatted to be more readable. However, the modified code introduces an async_scope
function with a very long line, making it harder to read and understand at a glance. Consider formatting the async_scope
call to align with typical Rust formatting conventions for better readability.Potential Misuse of await
in async
Block:
.await
inside the trace::scope
block, which was removed in the modified code. Ensure that the await
keyword is correctly placed within the async
block to avoid any potential issues with asynchronous execution. The await
keyword is crucial for properly awaiting the result of an asynchronous operation, and its absence could lead to unexpected behavior.Review Thread Safety:
printed
variable and any other shared mutable state are properly synchronized using appropriate locking mechanisms if needed.Improve Code Readability:
async_scope
call to improve readability, possibly by breaking it into multiple lines or using more descriptive variable names.Verify Correct Placement of await
:
await
keyword within the async
block to ensure that asynchronous operations are awaited correctly.By addressing these points, the code can be made more robust, readable, and maintainable.
What about this PR? I have another draft patch locally which is related to this patch and has git conflict with this patch. Kindly ping for review. Thanks a lot.
Currently, when using the command
moon test --trace
to record the test time, the output intrace.json
is not right. The duration is always0
(shown below).It is because the code in entry.rs just records the time to construct a
Future
instead of the time to run the test.This PR relies on https://github.com/moonbitlang/n2/pull/2 and can't be integrated before it. After merging these two PRs, the output should be right (as shown below).
Related Issues
Type of Pull Request
Does this PR change existing behavior?
Does this PR introduce new dependencies?
Checklist: