Are Workers good for small background 20000+ tasks...
# kotlin-native
k
Are Workers good for small background 20000+ tasks ? Are they remain unclosed after execute ? If yes I can attach new work to it after first work executed without recreating it ? (Like pool)
k
Worker essentially equals thread. you can submit as much work to it as you want after you start it.
k
Yahh so problem with pthreads was expensive to create so many instantly so Devs introduced Thread Pool. So I'm confused how to use workers as worker pool.
k
do you know that you need a pool?
k
I'm pooling lots of socket connections
k
what library are you using for that?
k
Nothing from scratch trying to use POSIX methods only
k
ah
well, i'm not aware of a multiplatform thread pool implementation
k
lookin into worker implementation. Its executing job and could attach another job without terminating itself
k
actually, the library Kevin linked claims to use a thread pool: https://github.com/Autodesk/coroutineworker#spawning-asynchronous-work
k
“could attach another job without terminating itself” By “terminating itself” do you mean the previous job or the worker? Worker is essentially 1 thread and a queue of jobs, that run in the order they’re submitted.
Disclaimer, I’ve never used the pool from coroutineworker. Just saw it in the code
k
Hahahaha... In code comment /* This function is magical operation */ 😂 so @elizarov and his team is doing magic.
Now I get it Pool is implemented by attaching jobs in queue in worker. So basically workers can create pool with just little work.
Thanks @Kris Wong and @kpgalligan guys for helping...
đŸ» 2