metarhia / metasync

Asynchronous Programming Library for JavaScript & Node.js
https://metarhia.com
MIT License
206 stars 35 forks source link

Refactor poolify function #376

Closed lundibundi closed 5 years ago

lundibundi commented 6 years ago

@tshemsedinov I'm not sure for the changes here but I don't see merit in 'poolify'ing functions and having to always pass an array to pool in order to place them back in the pool. With this it is not possible to poolify the functions but you can simply call pool(item) to put the item back in the pool.

If we have some good usage for poolify with functions I'll just remove the removal of support for them and this PR will only contain the remaining refactorings.

lundibundi commented 6 years ago

I used Array.isArray to distinguish get and put items.

Yes, I understood that, and the only reason for that IIUC is to have functions in a pool (or pool from functions). But I couldn't see any merit in having functions in a pool. In this https://github.com/metarhia/metasync/pull/376/files#diff-368334117fc46ee4b155e68d0966c0ecL97 test the pool will contain functions generated from their index in a pool, but what can it be used for?

tshemsedinov commented 6 years ago

We may hold closures and functors in pool because many abstractions may be implemented as instances of Function type

lundibundi commented 5 years ago

Could you clarify what sorts of abstractions may need to use Function, as I cannot come up with any?

tshemsedinov commented 5 years ago

@lundibundi for example we may write any system code or business logic with async contracts composed with metasync asynchronous composition that generates instances of Function type. We may want to use closures like objects for instantiation, so there are multiple cases.

nechaido commented 5 years ago

Closed due to inactivity, feel free to reopen this when the work is resumed.