Skip to content

Homework/02 multithreading - #79

Open
caoxhe wants to merge 7 commits into
eesast:mainfrom
caoxhe:main
Open

Homework/02 multithreading#79
caoxhe wants to merge 7 commits into
eesast:mainfrom
caoxhe:main

Conversation

@caoxhe

@caoxhe caoxhe commented Aug 5, 2026

Copy link
Copy Markdown

暑培:队式作业提交
基本信息
姓名:曹烜赫
班级:无55
学号:2025010295
提交说明
[x ] 已阅读并理解本次作业要求
#33

Copilot AI lite review requested due to automatic review settings August 5, 2026 12:23
@mergify

mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown

⚠️ The sha of the head commit of this PR conflicts with #43. Mergify cannot evaluate rules on this PR. Once #43 is merged or closed, Mergify will resume processing this PR. ⚠️

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  • TryDequeue uses 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 because Count > 0 here.
                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 thread src/LocalCli/Program.cs
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)

## 实现功能
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