transferables in gloo-worker
gloo-worker uses post_message to send serialized messages between workers. For some messages, it might be better to use post_message_with_transfer to send partially serialized messages while avoiding expensive copies. For example, if I had a struct like
struct Foo {
bar: i32,
baz: f64,
giant_array: web_sys::ArrayBuffer,
}
then I'd like to send this between workers by serializing the first two fields and transferring giant_array. Is this a use-case that gloo-worker is interested in supporting? The implementation I have in mind would involve custom Serialize-Deserialize-like traits and a derive macro...
(edit: I didn't mean to add the "bug" label, sorry, but it looks like I can't remove it)
Has any work been done to address this limitation? Or is there a workaround available somewhere else? This is something I really need right now.
I've been just doing my workers "by hand" instead of using gloo-worker. I'm "serializing" my structs to javascript Arrays by hand and using post_message_with_transfer. It's a bit painful, but it's doable if you only have a couple different kinds of structs to send.
I'm working on doing this "by hand" myself, and I found this trunk example to be instrumental in doing so.