2 ms·
In some situations, that is indeed a problem. In other situations, that is exactly what you want. For example, say you are passing a message along a sequence o
by quietbritishjim 8y ago
In some situations, that is indeed a problem. In other situations, that is exactly what you want.
For example, say you are passing a message along a sequence of threads (e.g. read from database in one thread, CPU-bound processing in the next, write back to database in the third). In that case, you probably want the lifetime of the request object to exactly match the time where there is an outstanding callback alive (either being called it waiting in a thread's queue).
The ownership model in that case is very clear: threads own queues which own callbacks which own shared pointers which own message handling objects.