Since you seem inexperienced in this I am not sure what level you mean ‘how’? But I will describe at a high level.
While std::async is interesting, I am still an old school programmer who uses threads directly, so I use juce::Thread, . I have a set of REST API class which derive from the thread class, and do all the things I described above. It uses a juce::ReferenceCountedObjectPtr to maintain lifetime. While I do use the class on it’s own, I usually roll a higher level Server class that presents all of the available REST API’s as member functions. These function instantiate a ServerTransaction class and return a juce::ReferenceCountedObjectPtr to the transaction object. If you don’t keep this reference, the object will delete itself when complete, otherwise it will stay valid until you release the reference (and it is complete).
