iandis / isolated_worker

An isolated worker for Flutter (Isolate) and Web (Web Worker). Behaves almost the same as the compute function, except it is not a one-off worker.
MIT License
42 stars 11 forks source link

Documentation not clear on worker re-use #16

Closed bsutton closed 2 years ago

bsutton commented 2 years ago

The documentation doesn't cover off if a IsolatedWorker is re-usable.

iandis commented 2 years ago

Hi, did you mean IsolatedWorker instance is able to be created or whether it is singleton or not? Please let me know if there's some context here I'm missing.

bsutton commented 2 years ago

So looking for clarity in the doco on how you fire off multiple jobs.

Can you re-use the worker or do you need to create a new one each time?

Can you run multiple jobs with the same worker simultaneously?

iandis commented 2 years ago

I think the docs have stated it clearly, that it spawns a singleton instance of worker. And about the multiple jobs, because it's Isolate/Web Worker, it is possible.

bsutton commented 2 years ago

Hmm, that fact that I'm asking suggests that the documentation doesn't contain sufficient info.

Just add some examples of reusing a worker so it's clear how to use it.

S. Brett Sutton Noojee Contact Solutions 03 8320 8100

On Wed, 8 Jun 2022 at 13:26, Iandi Santulus @.***> wrote:

I think the docs have stated it clearly, that it spawns a singleton instance of worker. And about the multiple jobs, because it's Isolate, it is possible.

— Reply to this email directly, view it on GitHub https://github.com/iandis/isolated_worker/issues/16#issuecomment-1149414420, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OHV25YQDYDAHWGUCOLVOAHGRANCNFSM5XTL3V4Q . You are receiving this because you authored the thread.Message ID: @.***>

bsutton commented 2 years ago

Some more thought on this.

The problem is that it doesn't detail how it manages isolates.

Does it's use a single isolate, a pool of isolates or does it start isolates as required?

If it uses multiple isolates how are they managed?

Will it start a thousand isolates if i do a thousand runs or does it limit the pool.

Does it reuse isolates or start a new isolate each time.

These are important consideration when choosing and using an isolate package as the can have considerable impact on performance.

On Wed, 8 June 2022, 1:26 pm Iandi Santulus, @.***> wrote:

I think the docs have stated it clearly, that it spawns a singleton instance of worker. And about the multiple jobs, because it's Isolate, it is possible.

— Reply to this email directly, view it on GitHub https://github.com/iandis/isolated_worker/issues/16#issuecomment-1149414420, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OHV25YQDYDAHWGUCOLVOAHGRANCNFSM5XTL3V4Q . You are receiving this because you authored the thread.Message ID: @.***>

iandis commented 2 years ago

I'm pretty sure it's already stated in the docs here and here. It clearly states that it is a singleton spawning a single Isolate.

bsutton commented 2 years ago

The fact that it is a singleton tells the reader nothing about how isolates are managed under the hood.

On Thu, 9 June 2022, 6:20 pm Iandi Santulus, @.***> wrote:

I'm pretty sure it's already stated in the docs here https://pub.dev/documentation/isolated_worker/latest/isolated_worker/IsolatedWorker-class.html and here https://pub.dev/documentation/isolated_worker/latest/isolated_worker/IsolatedWorker/IsolatedWorker.html. It clearly states that it is a singleton spawning a single Isolate.

— Reply to this email directly, view it on GitHub https://github.com/iandis/isolated_worker/issues/16#issuecomment-1150819613, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OHQ4YGRPZM7V4SL6EDVOGSMBANCNFSM5XTL3V4Q . You are receiving this because you authored the thread.Message ID: @.***>