×
Namespaces

Variants
Actions
(Difference between revisions)

WISE Thread Interface

From Nokia Developer Wiki
Jump to: navigation, search
ebra (Talk | contribs)
(Links)
ebra (Talk | contribs)
(Maemo Platform)
Line 4: Line 4:
 
== Maemo Platform ==
 
== Maemo Platform ==
 
<code>
 
<code>
 +
void* syncronize_thread(void* ptr);
 +
</code>
 +
<code>
 +
void callback_syncronize(GtkAction* action,gpointer data)
 +
{
 +
    pthread_t thread1,thread2;
 +
    MainView *view = get_mainview((void*)data);
  
 +
    if ( view->active ) show_note(view,"Note","Already running");
 +
    else if ( pthread_create(&thread1,NULL,syncronize_thread,(void*)view)==0 )
 +
        pthread_create(&thread2,NULL,update_screen_thread,(void*)view);
 +
}
 
</code>
 
</code>
  

Revision as of 15:37, 17 June 2008

Contents

Description

Maemo Platform

void* syncronize_thread(void* ptr);
void callback_syncronize(GtkAction* action,gpointer data)
{
pthread_t thread1,thread2;
MainView *view = get_mainview((void*)data);
 
if ( view->active ) show_note(view,"Note","Already running");
else if ( pthread_create(&thread1,NULL,syncronize_thread,(void*)view)==0 )
pthread_create(&thread2,NULL,update_screen_thread,(void*)view);
}

S60 Platform

TInt ThreadEntry(TAny* aPtr);
void CWISE_TESTAppView::RunEngineL(TInt aSyncType)
{
if ( iThread.ExitType()!=EExitPending ) iThread.Close();
 
iLogger->SetState(aSyncType);
User::LeaveIfError(iThread.Create(_L("WISEThread"),ThreadEntry,0x5000,
0x1000,0x1000000,iLogger));
 
iThread.Resume();
}
TInt ThreadFunction(TAny* aPtr)
{
CWISEEngine* engine = (CWISEEngine*)aPtr;
TInt state = engine->Logger().GetState();
if ( state < 2 )
{
if ( state==0 ) engine->SyncronizeClientL();
else engine->SyncronizeServerL();
engine->Logger().SetState(2);
}
else if ( state==3 )
{
engine->Logger().Flush();
CActiveScheduler::Stop();
}
return 0;
}
TInt ThreadEntry(TAny* aPtr)
{
CTrapCleanup* cleanupStack = CTrapCleanup::New();
if ( cleanupStack )
{
TRAPD( err,
CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler;
CleanupStack::PushL( scheduler );
CActiveScheduler::Install( scheduler );
 
CWISEEngine* eng = CWISEEngine::NewLC(*((CWISELogger*)aPtr));
 
CPeriodic* periodic = CPeriodic::NewL(CActive::EPriorityLow);
CleanupStack::PushL(periodic);
periodic->Start(1000, 1000000, TCallBack(ThreadFunction, eng));
 
CActiveScheduler::Start();
CleanupStack::PopAndDestroy(3);
);
delete cleanupStack;
cleanupStack = NULL;
}
return KErrNone;
}

Links

87 page views in the last 30 days.
×