Skip to content

Commit

Permalink
Added AEMainThreadEndpoint stress test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltyson committed Jul 2, 2016
1 parent 45e8614 commit 310aeb6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/AECrossThreadMessagingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ - (void)testMainThreadEndpointMessaging {
XCTAssertNil(weakEndpoint);
}

- (void)testMainThreadEndpointStressTest {
__block int counter = 0;
AEMainThreadEndpoint * endpoint = [[AEMainThreadEndpoint alloc] initWithHandler:^(const void *data, size_t length) {
counter++;
}];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
for ( int i=0; i<100; i++) {
AEMainThreadEndpointSend(endpoint, NULL, 0);
usleep(100);
}
});

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.2]];

XCTAssertEqual(counter, 100);
}

- (void)testAudioThreadEndpointMessaging {
NSMutableArray * messages = [NSMutableArray array];
AEAudioThreadEndpoint * endpoint = [[AEAudioThreadEndpoint alloc] initWithHandler:^(const void *data, size_t length) {
Expand Down

0 comments on commit 310aeb6

Please sign in to comment.