I'm trying to isolate a multithreading issue in my C++ application.
The Handler below gets created and "processed" within an auxiliary thread.
struct Handler
{
void process(const std::vector<size_t> ops)
{
std::vector<size_t>::const_iterator iter = ops.cbegin();
while( iter != ops.cend() ) {
processOperation( op );
}
}
void processOperation(std::vector<size_t>::const_iterator& iter)
{
size_t op = *iter;
iter++;
switch( op ) {
case frame_push : {
processOperation( iter );
break;
}
case frame_pop : {
return;
}
default : { break; }
}
}
};
As you can see in the above, processOperation() calls itself recursively if the current "op" equals frame_push.
I'm aware that sufficient recursive operations here would cause the call stack to overflow. However, when I run this Handler on an auxiliary thread instead of the main thread, that seems to happen much more quickly.
It seems like the possibility of a call stack overflow is not my only issue here. Might there be a reentrancy problem as well?
I would really appreciate any insights. Thanks!