Created
May 22, 2014 04:30
-
-
Save onevcat/9472fd86af5021bdecc9 to your computer and use it in GitHub Desktop.
Workaround for Unity game slowing in iPhone4 + 7.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Workaround for Unity game slowing in iPhone4 + 7.1 | |
//Write in main.mm | |
#include <pthread.h> | |
#include <dlfcn.h> | |
typedef int (*pthread_create_f)(pthread_t * __restrict, const pthread_attr_t * __restrict, void *(*)(void *), void * __restrict); | |
static pthread_create_f real_create = NULL; | |
extern "C" int pthread_create(pthread_t * __restrict thread, const pthread_attr_t * __restrict attr, void *(*start)(void *), void * __restrict arg) | |
{ | |
int rc; | |
if (!real_create) | |
real_create = (pthread_create_f)dlsym(RTLD_NEXT, "pthread_create"); | |
rc = (*real_create)(thread, attr, start, arg); | |
struct sched_param param; | |
int policy; | |
pthread_getschedparam(*thread, &policy, ¶m); | |
pthread_setschedparam(*thread, SCHED_FIFO, ¶m); | |
return rc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment