Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a thread agnostic class to manage wasm vms and plugins #279

Open
chaoqin-li1123 opened this issue Mar 21, 2022 · 0 comments
Open

Add a thread agnostic class to manage wasm vms and plugins #279

chaoqin-li1123 opened this issue Mar 21, 2022 · 0 comments

Comments

@chaoqin-li1123
Copy link
Contributor

chaoqin-li1123 commented Mar 21, 2022

Currently, getOrCreateThreadLocalWasm and getOrCreateThreadLocalPlugin use two static thread local hash maps to bookkeep the existing healthy wasm vms and wasm plugins. This is not compatible with envoy's thread local slot and prevent the wasm lifetime management code to be reused. It maybe cleaner to refactor the management of wasm vm and plugin into a WasmManager class which is thread agnostic and manage the lifetime of wasm vm and wasm plugins. Then the WasmManager can be use as a thread local variable in a more flexible way and we can put all the wasm management code there. The class can has interface that looks like

class WasmManager {
  WasmHandleSharedPtr getWasm(string vm_key);
  WasmHandleSharedPtr createWasm(string vm_key, ...);
  PluginHandleSharedPtr getPlugin(string vm_key, string plugin_key);
  PluginHandleSharedPtr createPlugin(wasm_handle, plugin, ...);
private:
  hash_map<string, WasmHandleSharedPtr> wasms_;
  hash_map<string, PluginHandleSharedPtr> plugins_;
};
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

No branches or pull requests

1 participant