Homework/02 multithreading - #79
Open
caoxhe wants to merge 7 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 完成了 02-multithreading 作业相关的若干 TODO:补齐日志解析(Request/Internal)、实现工作队列与多线程解析流程,并补全本地 CLI 交互与作业报告文档。
Changes:
- 在
LineParser中实现request/internal日志的反序列化与LogEntry构造,并补齐对应Accept/Visit逻辑。 - 实现
WorkQueue<T>与LogFileAnalyzer的多线程工作流(入队、工作线程解析、写回结果)。 - 完成
LocalCli控制台交互(列文件、指定/全部分析、查询结果)并新增02-multithreading报告。
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/LogParser/Visitors/KeyValueVisitor.cs | 为 Request/Internal 日志补齐键值对导出逻辑 |
| src/LogParser/Parser/LineParser.cs | 支持 request/internal 的解析与字段校验(JsonRequired) |
| src/LogParser/Models/LogEntries.cs | 补齐 Request/Internal 的 Visitor 分发(Accept) |
| src/LogAnalyzer/WorkQueue.cs | 实现工作队列的 Enqueue/TryDequeue/CompleteAdding |
| src/LogAnalyzer/LogFileAnalyzer.cs | 实现并发 worker 解析与结果写回 |
| src/LocalCli/Program.cs | 实现 CLI 菜单功能:展示、分析、查询结果 |
| docs/02-multithreading/report.md | 新增作业报告与截图说明 |
| docs/01-basic/report.md | 新增 01-basic 报告文档 |
Suppressed comments (1)
src/LogAnalyzer/WorkQueue.cs:47
TryDequeueuses the null-coalescing operator on_items.Dequeue(). This doesn’t compile for value-type queues (e.g.,WorkQueue<int>in the tests), and the thrown exception message is also unreachable becauseCount > 0here.
item = _items.Dequeue() ?? throw new InvalidOperationException("Queue is empty.");
Monitor.PulseAll(_items);
return true;
Comment on lines
+23
to
+27
| lock(_items){ | ||
| if (_isCompleted){ | ||
| throw new InvalidOperationException("Cannot enqueue a completed queue."); | ||
| } | ||
| _items.Enqueue(item); |
Comment on lines
+115
to
+119
| var _logfiles = analyzer.GetLogFiles(); | ||
| foreach (var file in _logfiles) | ||
| { | ||
| Console.WriteLine(file); | ||
| } |
|
|
||
| - 我使用了AI工具辅助 | ||
| - 第一次:由于我不会写文件的流式读取,导致 `parser.Parse` 参数类型不匹配,因此我在 VS Code 的 CC 插件中询问如下问题:"这段代码中 `result = parser.Parse(file);` 并不正确,`parser.Parse` 需要 `TextReader` 类型,应当如何修改?" | ||
| - 第二次:我借助了AI完成CLI:提示词为"根据 `docs/02-multiheading/guidance.md` 中对于 T2.3 的要求,完成 `Program.cs`" |
Comment on lines
+1
to
+3
| # Report: LocalCli Console Interface (T2.3) | ||
|
|
||
| ## 实现功能 |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
暑培:队式作业提交
基本信息
姓名:曹烜赫
班级:无55
学号:2025010295
提交说明
[x ] 已阅读并理解本次作业要求
#33