2022-12-25 07:36:00 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
|
|
|
|
#include "cscore_runloop.h"
|
|
|
|
|
|
|
|
|
|
#include <CoreFoundation/CFRunLoop.h>
|
2022-12-25 11:37:59 -08:00
|
|
|
#import <Foundation/Foundation.h>
|
2022-12-25 07:36:00 -08:00
|
|
|
|
|
|
|
|
namespace cs {
|
2022-12-25 11:37:59 -08:00
|
|
|
void RunMainRunLoop() {
|
|
|
|
|
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
|
|
|
|
|
NSLog(@"This method can only be called from the main thread");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-12-25 07:36:00 -08:00
|
|
|
CFRunLoopRun();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-25 11:37:59 -08:00
|
|
|
int RunMainRunLoopTimeout(double timeoutSeconds) {
|
|
|
|
|
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
|
|
|
|
|
NSLog(@"This method can only be called from the main thread");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-12-25 07:36:00 -08:00
|
|
|
return CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeoutSeconds, false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-25 11:37:59 -08:00
|
|
|
void StopMainRunLoop() {
|
2022-12-25 07:36:00 -08:00
|
|
|
CFRunLoopStop(CFRunLoopGetMain());
|
|
|
|
|
}
|
|
|
|
|
}
|