I have a function that takes a pointer to some memory that is memory mapped, I want to perform some computation on this memory using a parallel_for loop. The problem is that accessing this pointer can cause blocking if the specific page is not yet transferred into system memory, my question is, how should I handle such a scenario? Would something like the following work properly?
void foo(char* dest, char* source, int size)
{
assert(size < 128 * 1000);
// "source" could be a memory mapped file.
VirtualLock(source, size); // Will this block until the requested data is in memory?
tbb::parallel_for(tbb::blocked_range(0, size), [dest, source](const tbb::blocked_range& r)
{
// Read from "source" without blocking the task-scheduler? ...
});
VirtualUnlock(ptr, size);
}



