TellmePdmsPluging/Core/SafeQueue.cs
sladro 8f5bcc0c98 添加模型缩减和项目打开功能的API支持
- 在HttpServer中实现了新的API端点:/api/project/open和/api/model/shrinkwrap
- 添加了ShrinkwrapModel和OpenProject命令的处理逻辑
- 在PdmsManager中实现了ShrinkwrapModel和OpenProject方法,支持相应请求的处理
- 更新了项目文件以包含新的命令和模型请求类

此更新增强了插件的功能,允许用户通过API进行模型缩减和项目打开操作。
2026-02-05 08:22:42 +08:00

68 lines
1.4 KiB
C#

using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace TellmePdmsPluging.Core
{
public static class SafeQueue
{
private static readonly object _sync = new object();
private static Queue<ICommand> _queue;
public static void Init()
{
if (_queue != null)
{
return;
}
lock (_sync)
{
if (_queue == null)
{
_queue = new Queue<ICommand>();
}
}
}
public static void Enqueue(ICommand command)
{
if (command == null)
{
return;
}
Init();
lock (_sync)
{
_queue.Enqueue(command);
}
}
public static bool TryDequeue(out ICommand command)
{
Init();
lock (_sync)
{
if (_queue.Count > 0)
{
command = _queue.Dequeue();
return true;
}
}
command = null;
return false;
}
}
public interface IResultCommand : ICommand
{
object Result { get; }
Exception Error { get; }
bool IsCompleted { get; }
}
}