【发布时间】:2014-10-06 03:07:43
【问题描述】:
我有这个代码:
Matrix mat;
for (int y=0; y<n; ++y)
{
for (int x=0; x<m; ++x)
{
// do some small operation on mat(y,x)
}
};
串行计算很慢(这个双循环被称为500-1000次),所以第一步我想用dispatch_apply并行化它。
Matrix mat;
dispatch_apply(PATCH_SIZE, _queue, ^(size_t y)
{
for (int x=0; x<m; ++x)
{
// do some small operation on mat(y,x)
}
});
问题在于变量mat,它在块内被定义为只读。有没有办法解决这个问题?
【问题讨论】:
标签: objective-c objective-c-blocks grand-central-dispatch