|
@@ -16,6 +16,8 @@
|
|
@property (nonatomic, strong) UITableView *videoListTableView;
|
|
@property (nonatomic, strong) UITableView *videoListTableView;
|
|
@property (nonatomic, strong) NSMutableArray *videoDataSource;
|
|
@property (nonatomic, strong) NSMutableArray *videoDataSource;
|
|
@property (nonatomic, strong) dispatch_queue_t videoListQueue;
|
|
@property (nonatomic, strong) dispatch_queue_t videoListQueue;
|
|
|
|
+@property (nonatomic, strong) dispatch_semaphore_t signalSemaphore;
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
|
|
@@ -28,6 +30,7 @@
|
|
if (self) {
|
|
if (self) {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self addSubview:self.videoListTableView];
|
|
[self addSubview:self.videoListTableView];
|
|
|
|
+ _signalSemaphore = dispatch_semaphore_create(1);
|
|
[self getDataSource];
|
|
[self getDataSource];
|
|
}
|
|
}
|
|
return self;
|
|
return self;
|
|
@@ -36,6 +39,7 @@
|
|
- (void)getDataSource {
|
|
- (void)getDataSource {
|
|
// 自己第一,讲师第二
|
|
// 自己第一,讲师第二
|
|
dispatch_async(self.videoListQueue, ^{
|
|
dispatch_async(self.videoListQueue, ^{
|
|
|
|
+ MJ_LOCK(self.signalSemaphore)
|
|
NSArray *tempArray = [ClassroomService sharedService].currentRoom.memberList;
|
|
NSArray *tempArray = [ClassroomService sharedService].currentRoom.memberList;
|
|
if (tempArray.count <= 0) {
|
|
if (tempArray.count <= 0) {
|
|
return;
|
|
return;
|
|
@@ -68,12 +72,14 @@
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.videoDataSource = [lastArray mutableCopy];
|
|
self.videoDataSource = [lastArray mutableCopy];
|
|
[self.videoListTableView reloadData];
|
|
[self.videoListTableView reloadData];
|
|
|
|
+ MJ_UNLOCK(self.signalSemaphore)
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- (void)updateUserVideo:(NSString *)userId {
|
|
- (void)updateUserVideo:(NSString *)userId {
|
|
dispatch_async(self.videoListQueue, ^{
|
|
dispatch_async(self.videoListQueue, ^{
|
|
|
|
+ MJ_LOCK(self.signalSemaphore)
|
|
for(int i=0;i<self.videoDataSource.count;i++) {
|
|
for(int i=0;i<self.videoDataSource.count;i++) {
|
|
RoomMember *member = self.videoDataSource[i];
|
|
RoomMember *member = self.videoDataSource[i];
|
|
if([member.userId isEqualToString:userId]) {
|
|
if([member.userId isEqualToString:userId]) {
|
|
@@ -86,6 +92,7 @@
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ MJ_UNLOCK(self.signalSemaphore)
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|