Skip to content

Commit

Permalink
use IDisposable
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje committed Oct 29, 2019
1 parent 3f632ea commit ce807ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 4 additions & 1 deletion neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public void Dispose()
{
RpcServer?.Dispose();
EnsureStoped(LocalNode);
Plugin.NotifyPluginsToShutdown();
foreach (var p in Plugin.Plugins)
{
p.Dispose();
}
// Dispose will call ActorSystem.Terminate()
ActorSystem.Dispose();
ActorSystem.WhenTerminated.Wait();
Expand Down
16 changes: 5 additions & 11 deletions neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Neo.Plugins
{
public abstract class Plugin
public abstract class Plugin : IDisposable
{
public static readonly List<Plugin> Plugins = new List<Plugin>();
private static readonly List<ILogPlugin> Loggers = new List<ILogPlugin>();
Expand Down Expand Up @@ -62,10 +62,6 @@ protected virtual void OnPluginsLoaded()
{
}

protected virtual void OnShutdown()
{
}

private static void ConfigWatcher_Changed(object sender, FileSystemEventArgs e)
{
foreach (var plugin in Plugins)
Expand Down Expand Up @@ -116,12 +112,6 @@ internal static void NotifyPluginsLoadedAfterSystemConstructed()
plugin.OnPluginsLoaded();
}

internal static void NotifyPluginsToShutdown()
{
foreach (var plugin in Plugins)
plugin.OnShutdown();
}

protected void Log(string message, LogLevel level = LogLevel.Info)
{
Log($"{nameof(Plugin)}:{Name}", level, message);
Expand Down Expand Up @@ -179,5 +169,9 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
return null;
}
}

public virtual void Dispose()
{
}
}
}

0 comments on commit ce807ba

Please sign in to comment.