mirror of https://github.com/axmolengine/axmol.git
update pthread implement
This commit is contained in:
parent
2bd49545fa
commit
42775d4ec5
|
@ -20,15 +20,17 @@
|
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <FApp.h>
|
||||
#include "pthread.h"
|
||||
|
||||
typedef void*(*pthread_func)(void *);
|
||||
#include <FApp.h>
|
||||
#include <FBaseRtThread.h>
|
||||
|
||||
using namespace Osp::Base;
|
||||
using namespace Osp::Base::Runtime;
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef void*(*pthread_func)(void *);
|
||||
|
||||
//struct _pthread_fastlock
|
||||
//{
|
||||
// int __spinlock;
|
||||
|
@ -122,6 +124,10 @@ int pthread_create(pthread_t*__threadarg,
|
|||
void*(*__start_routine)(void *),
|
||||
void*__arg)
|
||||
{
|
||||
if (NULL == __threadarg)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
Thread *thread = new Thread();
|
||||
RunnableProxy *proxy = new RunnableProxy();
|
||||
proxy->SetFunc(__start_routine);
|
||||
|
@ -142,7 +148,7 @@ int pthread_join(pthread_t __th,void**__thread_return)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
return __th->Join();
|
||||
return ((Thread*)__th)->Join();
|
||||
}
|
||||
|
||||
int pthread_cancel(pthread_t thread)
|
||||
|
@ -151,14 +157,14 @@ int pthread_cancel(pthread_t thread)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
return thread->Exit();
|
||||
return ((Thread*)thread)->Exit();
|
||||
}
|
||||
|
||||
int pthread_detach(pthread_t __th)
|
||||
{
|
||||
if (__th)
|
||||
{
|
||||
__th->Exit();
|
||||
((Thread*)__th)->Exit();
|
||||
delete __th;
|
||||
}
|
||||
return 0;
|
||||
|
@ -170,7 +176,7 @@ int pthread_equal(pthread_t __thread1,pthread_t __thread2)
|
|||
{
|
||||
return (void *)__thread1 == (void *)__thread2;
|
||||
}
|
||||
return __thread1->Equals(*__thread2);
|
||||
return ((Thread*)__thread1)->Equals(*((Thread*)__thread2));
|
||||
}
|
||||
|
||||
int pthread_kill(pthread_t thread,int sig)
|
||||
|
@ -179,7 +185,7 @@ int pthread_kill(pthread_t thread,int sig)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
return thread->Exit(sig);
|
||||
return ((Thread*)thread)->Exit(sig);
|
||||
}
|
||||
|
||||
int pthread_attr_init(pthread_attr_t*attr)
|
||||
|
@ -383,3 +389,5 @@ int pthread_condattr_setpshared(pthread_condattr_t*attr,int pshared)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
|
||||
#ifndef PTHREAD_H_
|
||||
#define PTHREAD_H_
|
||||
#include <FBaseRtThread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PTHREAD_STACK_SIZE Osp::Base::Runtime::DEFAULT_STACK_SIZE
|
||||
#define PTHREAD_STACK_SIZE (64*1024)
|
||||
#define PTHREAD_STACK_MINSIZE 16384
|
||||
#define PTHREAD_THREADS_MAX 1024
|
||||
|
||||
|
@ -37,9 +39,7 @@
|
|||
#define PTHREAD_KEYS_MAX 32
|
||||
|
||||
|
||||
typedef Osp::Base::Runtime::Thread* pthread_t;
|
||||
|
||||
|
||||
typedef void* pthread_t;
|
||||
struct pthread_mutex;
|
||||
typedef struct pthread_mutex* pthread_mutex_t;
|
||||
struct pthread_attr;
|
||||
|
@ -243,7 +243,7 @@ int pthread_create(pthread_t*__threadarg,
|
|||
void*(*__start_routine)(void *),
|
||||
void*__arg);
|
||||
|
||||
void pthread_exit(void*__retval) __attribute__((__noreturn__));
|
||||
void pthread_exit(void*__retval);
|
||||
|
||||
int pthread_join(pthread_t __th,void**__thread_return);
|
||||
|
||||
|
@ -252,4 +252,8 @@ int pthread_equal(pthread_t __thread1,pthread_t __thread2);
|
|||
|
||||
//int pthread_sigmask(int how,const sigset_t*newset,sigset_t*oldset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PTHREAD_H_ */
|
||||
|
|
Loading…
Reference in New Issue