Naios / continuable

C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections)
https://naios.github.io/continuable/
MIT License
815 stars 44 forks source link

Feature Request/Question: zero-allocation support #10

Closed koraa closed 5 years ago

koraa commented 5 years ago

Thanks for your great library; I am excited to finally see proper promises in C++ :D Now to my question: Would it be possible to support environments in which allocation is not an option? Under which conditions are allocations mandatory at the moment?

Naios commented 5 years ago

Hey, I'm glad that you like the library. Continuable does an allocation in following two circumstances:

Probably it would be possible to store the promises of an unknown type in a preallocated space, so you could ellide the memory allocation completely when deferring the promise resolution.

Avoiding the memory allocation for the shared state in connections is currently not possible nor planned.

koraa commented 5 years ago

Thanks for your quick response :) I am still trying to wrap my head around the library…

In my use case I just wouldn't use type erasure, so that would be fine, but the connections using allocation would be a problem in an allocation-free application… Thanks for the infos anyways :)