HarlonWang / quickjs-wrapper

QuickJS wrapper for Android/JVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make QuickJSContext implements AutoCloseable

ag2s20150909 opened this issue · comments

使QuickJSContext实现 AutoCloseable,现在销毁 JSContext 需要执行两个方法,太麻烦了。

JSRuntime 和 JSContext 是一对多的关系,有两种使用场景:

  1. 同时销毁 JSContext 和 JSRuntime
  2. 只销毁 JSContext,不销毁 JSRuntime

所有这里是分成了两个方法来销毁,AutoCloseable 可以在场景1里实现,但是在场景2下就不太好实现了。

PS: 如果你有更好的建议,欢迎提出 :)