There’s a large shared object (kind of OpenGL context) in my project. It is accessed from multiple threads. To ensure only one thread at the moments is using
SHARED_OBJECT, mutex (kind of
NSRecursiveLock) is used.
The problem is that sometimes
MAIN_THREAD is waiting a lot while some
BG_THREAD is doing something with
I am not supposed to change architecture (to rewrite this mutex scheme).
The current problem lies in following: There is
my_backround_func (takes a lot of time), which is called before
main_thread_func1(takes few milliseconds) and
These functions are spread all over the project. To fix the problem, I created singleton class
Dispatcher, which lets
main_thread_func* to be registered, and lets
my_backround_func to ask if all
main_thread_funcs were already executed.
It uses Objective C mechanisms like
NSStringFromSelector and “
At the start of the program I register functions:
[[MyBackgroundFunctionDispatcher dispatcher] setCanCallBgFunc:NO forSelector:NSStringFromSelector(@selector(main_thread_func1:))]; [[MyBackgroundFunctionDispatcher dispatcher] setCanCallBgFunc:NO forSelector:NSStringFromSelector(@selector(main_thread_func2:))];
And at the end of
main_thread_func2 I call
[[MyBackgroundFunctionDispatcher dispatcher] setCanCallBgFunc:YES forSelector:NSStringFromSelector(_cmd)];
All this time background thread is waiting:
while ( ![[MyBackgroundFunctionDispatcher dispatcher] setCanCallBgFunc] ) sleep_ms(10);
So, I ensured that background function will be caller AFTER registered main thread functions.
MyBackgroundFunctionDispatcher can be extended to hold registered functions not only for
my_backround_func, but for
While the solution looks ugly and I suspect I miss some good pattern.
Could you give any advices please?
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!