Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semaphore object deallocated while in use Abort Cause 1 报错 #16

Open
shaobinbin0621 opened this issue Sep 11, 2019 · 1 comment
Open

Comments

@shaobinbin0621
Copy link

谷歌了下,
` semaphore = dispatch_semaphore_create(1);

//异步执行
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    //将数据 转换为 BMChineseSortModel
    NSMutableArray *sortModelArray = [NSMutableArray arrayWithCapacity:0];
    [objectArray enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        BMChineseSortModel *model = [self getModelWithObj:obj key:key];
        if (model) {
            //对 数组的插入操作 上锁
            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
                [sortModelArray addObject:model];
            dispatch_semaphore_signal(semaphore);
        }
    }];`

系统判断sema是否被使用的标志为sema被销毁时的值是否与初始化的值相同

@zhoumingwu
Copy link

解决了吗,我也遇到相同问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants