Symbian has pthreads support, but it sucks, yesterday i discovered it has a maximum number of threads you can create, that is
void *dumb_thread(void *)
{
pthread_exit(NULL)
}
function_somewhere_in_my_code()
{
pthread_t t;
int error = pthread_create(&t, NULL, dumb_thread, NULL);
check_error();
pthread_join(t, NULL);
call_function_somewhere_in_my_code_though_a_timer();
}
will end up returning error 35 (EAGAIN) in pthread_create after some calls, depending on the phone it can be 20000 or 60000, and yes, that's a lot of threads, but if you are using threads for fire and forget jobs it's relatively easy to hit that number, so i've been forced to implement a thread pool just to workaround yetAnotherSymbianBug.
And yes, this has nothing to do with KDE, except that the more i code in Symbian the more i appreciate the rock solid API provided by KDE and Qt
A blog about random things and sometimes about my work translating and developing KDE and anything
Showing posts with label pthread. Show all posts
Showing posts with label pthread. Show all posts
Friday, August 07, 2009
Thursday, December 18, 2008
Symbian C++ sucks
Let's say you are developing on a Symbian phone. You are creating something more complex than a "Hello World" app so you need threads.
You create a RThread, and inside that thread you append things to a RArray (dynamic array) and then from the main thread you want to retrieve them.
NO! You can't! Accessing elements of a RArray from two different RThreads is not allow and it'll crash on you.
Ok you think, they just ported STL to Symbian, let's use a std::list, and NO! It'll crash even earlier.
So you are about to throw the phone across the window, but then you think, wait the also ported some POSIX things to Symbian, and try pthread and it suddenly works and you realize how simple things can be a nightmare when using weird tools/SDK, that's why Qt rocks it gives you almost all you want in a practical API, and when something is missing KDE adds the missing bit.
You create a RThread, and inside that thread you append things to a RArray (dynamic array) and then from the main thread you want to retrieve them.
NO! You can't! Accessing elements of a RArray from two different RThreads is not allow and it'll crash on you.
Ok you think, they just ported STL to Symbian, let's use a std::list, and NO! It'll crash even earlier.
So you are about to throw the phone across the window, but then you think, wait the also ported some POSIX things to Symbian, and try pthread and it suddenly works and you realize how simple things can be a nightmare when using weird tools/SDK, that's why Qt rocks it gives you almost all you want in a practical API, and when something is missing KDE adds the missing bit.
Subscribe to:
Posts (Atom)