-
I'd appreciate some help getting a SharedWorker to do something for me... I put together a basic example and am getting an error when creating the SharedWorker:
main.ts:
imuworker.ts:
Full project: Adding the minimumOptions makes no difference. I saw those in https://github.com/Moddable-OpenSource/moddable/blob/public/tests/modules/base/sharedworker/messages.js#L19 but they don't really make sense to me: doesn't a sharedworker use the same VM as main? I thought that was the point of a shared worker? (I guess there needs to be a separate stack?) I would appreciate some help, both in getting this to work and in understanding a bit better what a shared worker in xs is. (I have never used a worker in JS, so the whole topic is new to me.) As background, I'm trying to run a 100Hz interrupt handler type task in a shared worker to update IMU information and hope that will run time-sliced with poco.end. Dunno whether that's actually doable... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I'd suggest starting with a regular worker. They are almost always enough and a bit simpler. From what you describe, that seems to be the case here. There is an example of workers in this repository. That's a good place to start exploring. Workers (and Shared Workers) in the Moddable SDK are documented.
No.
Yes, it will. On an ESP32 those will run independently on separate cores. They can only run independently if they are separate VMs, naturally. |
Beta Was this translation helpful? Give feedback.
-
Can you clarify the memory allocation a little for me? |
Beta Was this translation helpful? Give feedback.
I'd suggest starting with a regular worker. They are almost always enough and a bit simpler. From what you describe, that seems to be the case here.
There is an example of workers in this repository. That's a good place to start exploring.
Workers (and Shared Workers) in the Moddable SDK are documented.
No.
Yes, it will. On an ESP32 those will run independently on separate cores. They can only run independently if they are separate VMs, naturally.