Initial commit: Client Doc docs Server Tools
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using XWorld.Framework;
|
||||
|
||||
namespace XWorld.Server.Host
|
||||
{
|
||||
public sealed class LoadedGameModule
|
||||
{
|
||||
public string GameId { get; }
|
||||
public int Version { get; }
|
||||
public Func<IGameServerRoom> CreateRoom { get; private set; }
|
||||
|
||||
private GameModuleAlc _alc; // 强引用;Unload 时置空
|
||||
|
||||
internal LoadedGameModule(string gameId, int version, GameModuleAlc alc, Func<IGameServerRoom> factory)
|
||||
{
|
||||
GameId = gameId; Version = version; _alc = alc; CreateRoom = factory;
|
||||
}
|
||||
|
||||
// 卸载并返回 ALC 弱引用,便于上层做 GC 内存回收断言
|
||||
public WeakReference Unload()
|
||||
{
|
||||
var alc = _alc;
|
||||
_alc = null;
|
||||
// 切断工厂闭包对 entryType→Assembly→ALC 的引用链;卸载后再调用即抛错
|
||||
CreateRoom = () => throw new ObjectDisposedException($"GameModule {GameId}@{Version} 已卸载");
|
||||
var weak = new WeakReference(alc);
|
||||
alc.Unload();
|
||||
return weak;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user