src/thread/epoc/SDL_systhread.cpp
changeset 2126 9c9c49b18693
parent 2125 fab12febc0f9
child 2127 3bcc26b74e42
     1.1 --- a/src/thread/epoc/SDL_systhread.cpp	Fri Jun 15 12:27:43 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,124 +0,0 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     1.7 -
     1.8 -    This library is free software; you can redistribute it and/or
     1.9 -    modify it under the terms of the GNU Library General Public
    1.10 -    License as published by the Free Software Foundation; either
    1.11 -    version 2 of the License, or (at your option) any later version.
    1.12 -
    1.13 -    This library is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 -    Library General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU Library General Public
    1.19 -    License along with this library; if not, write to the Free
    1.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 -
    1.22 -    Sam Lantinga
    1.23 -    slouken@libsdl.org
    1.24 -*/
    1.25 -#include "SDL_config.h"
    1.26 -
    1.27 -/*
    1.28 -    SDL_systhread.cpp
    1.29 -    Epoc thread management routines for SDL
    1.30 -
    1.31 -    Epoc version by Markus Mertama  (w@iki.fi)
    1.32 -*/
    1.33 -
    1.34 -
    1.35 -extern "C" {
    1.36 -#undef NULL
    1.37 -#include "SDL_error.h"
    1.38 -#include "SDL_thread.h"
    1.39 -#include "../SDL_systhread.h"
    1.40 -    };
    1.41 -
    1.42 -#include <e32std.h>
    1.43 -
    1.44 -
    1.45 -static int object_count;
    1.46 -
    1.47 -int RunThread(TAny* data)
    1.48 -{
    1.49 -	SDL_RunThread(data);
    1.50 -	return(0);
    1.51 -}
    1.52 -
    1.53 -
    1.54 -TInt NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
    1.55 -    {
    1.56 -    return ((RThread*)(aPtr1))->Create(aName,
    1.57 -            RunThread,
    1.58 -            KDefaultStackSize,
    1.59 -            NULL,
    1.60 -            aPtr2);
    1.61 -    }
    1.62 -
    1.63 -int CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny* aPtr1, TAny* aPtr2)
    1.64 -    {
    1.65 -    TBuf<16> name;
    1.66 -    TInt status = KErrNone;
    1.67 -    do
    1.68 -        {
    1.69 -        object_count++;
    1.70 -        name.Format(_L("SDL_%x"), object_count);
    1.71 -        status = aFunc(name, aPtr1, aPtr2);
    1.72 -        }
    1.73 -        while(status == KErrAlreadyExists);
    1.74 -    return status;
    1.75 -    }
    1.76 -
    1.77 -
    1.78 -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
    1.79 -{
    1.80 -    RThread rthread;
    1.81 -   
    1.82 -    TInt status = CreateUnique(NewThread, &rthread, args);
    1.83 -    if (status != KErrNone) 
    1.84 -    {
    1.85 -        delete(((RThread*)(thread->handle)));
    1.86 -        thread->handle = NULL;
    1.87 -		SDL_SetError("Not enough resources to create thread");
    1.88 -		return(-1);
    1.89 -	}
    1.90 -	rthread.Resume();
    1.91 -    thread->handle = rthread.Handle();
    1.92 -	return(0);
    1.93 -}
    1.94 -
    1.95 -void SDL_SYS_SetupThread(void)
    1.96 -{
    1.97 -	return;
    1.98 -}
    1.99 -
   1.100 -Uint32 SDL_ThreadID(void)
   1.101 -{
   1.102 -    RThread current;
   1.103 -    TThreadId id = current.Id();
   1.104 -	return id;
   1.105 -}
   1.106 -
   1.107 -void SDL_SYS_WaitThread(SDL_Thread *thread)
   1.108 -{
   1.109 -    RUndertaker taker;
   1.110 -    taker.Create();
   1.111 -    TRequestStatus status;
   1.112 -    taker.Logon(status, thread->handle);
   1.113 -    User::WaitForRequest(status);
   1.114 -    taker.Close();
   1.115 -}
   1.116 -
   1.117 -/* WARNING: This function is really a last resort.
   1.118 - * Threads should be signaled and then exit by themselves.
   1.119 - * TerminateThread() doesn't perform stack and DLL cleanup.
   1.120 - */
   1.121 -void SDL_SYS_KillThread(SDL_Thread *thread)
   1.122 -{
   1.123 -    RThread rthread;
   1.124 -    rthread.SetHandle(thread->handle);
   1.125 -	rthread.Kill(0);
   1.126 -	rthread.Close();
   1.127 -}