PDA

View Full Version : multi-threaded game/application???


Sinful Desires
08-29-2003, 09:46 AM
Is BREW compatible of developing multi-threaded game/application???

jhw
08-29-2003, 09:55 AM
BREW is strictly event-driven single thread. You will have to fake it with your own cooperative multitasking.

ruben
08-29-2003, 09:58 AM
In BREW 2.1 there is API for co-operative multi-tasking thread, IThread.

I have used it in emulator and it works fine, but I have yet to test the performance in 2.1 device.

ruben

yunhuafu
02-10-2004, 10:19 AM
hi, I was trying to implement mulit thread , my problems is within the function the thread, aftre start, the pIThread in start becomes NULL, so, how can I use getResumeCBK then, I want to get the current thread, any suggestion or sample code?

Many thanks

ruben
02-10-2004, 01:23 PM
Are you using IThread? Post the code snippet.

In order to use IThread, first you need to create it, then call start function. In your start callback function intialize thread local storage and then use it. After that call your thread worker function.

ruben

yunhuafu
02-10-2004, 01:42 PM
thank you, I know I should createInstance then start
though I don't know how to deal with TLS, could you show a few lines for it? I can not get it from SDK.

Many thanks

yunhuafu
02-10-2004, 01:50 PM
my code:

ret=ITHREAD_Start(pMe->pIThread[i] ,1024,(PFNTHREAD)ftp, pMe);

void ftp(ithreadtest *pMe)
{
if (pMe->pIThread==NULL)
......
}

ruben
02-10-2004, 02:07 PM
Thread local storage is not mandatory, but you can use this to get access to your applet or other data pointers in any thread functons.

ISHELL_CreateInstance (.... AEECLSID_THREAD...)
ITHREAD_Start (.., 100, (PFNTHREAD)ThreadEntry, pApp); (where pApp is pointer to your applet class/structure)


static void ThreadEntry ( IThread* pCurThread, Void* pUserData)
{
Container* pApp = (Container*)pUserData; // "Container" is my main module class/structure
AEETls aTls;
AEETLS_INIT( aTls, pCurThread);
IThread_SetTLS ( "pApp", pApp );

// Call here your worker function
}

To get access to your app pointer you do the following
Container* pApplet;
IThread_GetTLS ( "pApp", (void**)&pApplet );

ruben

skumar_rao
02-12-2004, 09:16 PM
this can help u

[URL=http://www.developer.com/ws/brew/article.php/2242101]

ruben
02-13-2004, 06:32 AM
IThread is a based on callback implementation of co-operative thread. It gives you functionalites like mutex etc.

ruben

mcho
03-30-2005, 04:18 PM
Hello,

I'd like to be able to upload a bunch of files in a background thread, using ithread. I was thinking of doing the following:


1 - Get list of files in directory, and store in main structure
2 - Start a thread
3 - Within thread, use IWEB to upload file to server
4 - In IWeb callback, if there's more files to upload, get next file and call step 3.

I'm assuming that once I start a thread in step 2, I can just go back to the main menu, having the thread work as a background process. Is this true?

If someone has some sample code on using ithread, it would be much appreciated. I saw how to instantiate and start a thread, but how do we use
callbacks (GetResumeCBK), and specify a callback function? Does everything involving the thread work as a background process?


Thanks.