Hi all,
I have a problem when porting game to windows phone 8. In project win32 I use pthread.h but it not working in windows phone 8.
And I find in CCTextureCache of core cocos2d-x, all variable and funtion related to pthread has been put in comment.
eg: in CCTextureCache.cpp
//static pthread_mutex_t s_asyncStructQueueMutex;
//static pthread_mutex_t s_ImageInfoMutex;
or:
//pthread_mutex_lock(&s_asyncStructQueueMutex);
How can i solve this problem?
I have same problem, do you have resolved?
bye
chenjc
March 19, 2014, 8:18am
#3
I found wp8 use function in CCPThreadWinRT.h instead of pthread. It seems ok now. Any detail of function that you need?
@chenjc wrote:
I found wp8 use function in CCPThreadWinRT.h instead of pthread. It seems ok now. Any detail of function that you need?
How do you change HttpClient.cpp from pthread to CCPThreadWinRT?
Thanks!!!
kuhar
March 19, 2014, 9:38am
#6
You can simply use std::thread
, transition is usually pretty straight-forward.
And I recommend C++ REST SDK (casablanca) as a replacement for HTTPClient.
@chenjc wrote:
I found wp8 use function in CCPThreadWinRT.h instead of pthread. It seems ok now. Any detail of function that you need?
I tried include CCPThreadWinRT, but, what do you have inserted instead pthread_create, pthread_exit?
bye and thanks!!
chenjc
March 19, 2014, 3:47pm
#9
Hi @lordubik , there is a pr about httpclient, libcurl, libwebsocket: https://github.com/cocos2d/cocos2d-x/pull/5098 , I added some fix to let it auto-merged and will merged soon. And httpclient works well. Thanks.
kuhar
March 19, 2014, 4:16pm
#10
but std::thread is not only for c++11? can I set c++11 in visual studio to compile my project and cocos2.2.3?
Yes, it’s c++11 only. There is no switch to choose between c++ standards in VC, c++11 is default and only once since VC10.
@chenjc wrote:
Hi @lordubik , there is a pr about httpclient, libcurl, libwebsocket: https://github.com/cocos2d/cocos2d-x/pull/5098 , I added some fix to let it auto-merged and will merged soon. And httpclient works well. Thanks.
I looked the HTTPClient changes and I have applied the changes… but pthread_create is a empty function:
define pthread_create(w,x,y,z) 1
define pthread_detach(x)
I have wrong something?
Thanks for help!!
dungmv
March 20, 2014, 5:14pm
#12
i have used this code for httpclient wp8
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2014 Martell Malone < martell malone at g mail dot com >
Copyright (c) 2012 greathqy
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
This file has been truncated. show original
@dungmv wrote:
i have used this code for httpclient wp8
https://github.com/martell/cocos2d-x/blob/curlwinrt/extensions/network/HttpClient.cpp
yes I have taken the same code; but where is pthread_create? because inside CCPThreadWinRT.h there is a empty declaration…
I need httpclient for take a file from a website.
Thanks!
chenjc
March 21, 2014, 2:03am
#14
@lordubik , it is not use pthread_create but use create_task to call sendRequest.
dungmv
March 21, 2014, 2:30am
#15
see here
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
Copyright (c) Microsoft Open Technologies, Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
This file has been truncated. show original
I think cocos v2 should create class thread for cocos. so, we can use same code for thread on all platfrom
chenjc
March 21, 2014, 3:17am
#16
@dungmv @lordubik , do you use pthread function in your other game codes frequently? If so, Maybe we need to create implements for pthread function like pthread_create…
dungmv
March 21, 2014, 4:28am
#17
yes. AI of game need multi thread
@chenjc wrote:
@dungmv @lordubik , do you use pthread function in your other game codes frequently? If so, Maybe we need to create implements for pthread function like pthread_create…
Hi, thanks for help me.
I don’t use pthread and createtask works well!
Thanks!
chenjc
March 26, 2014, 2:32am
#20
@dungmv I replace pthread with std::thread and test ok, using macros.
Thanks!
Now I have another problem… I have compiled libcurl for release… but I have this errors:
1>lib\multi.c(826): error C2027: use of undefined type ‘pollfd’
1> c:\users\stefano\works\cocos2d-x-2.2.3\cocos2dx\platform\third_party\wp8\libcurl\lib\select.h(90) : see declaration of ‘pollfd’
1>lib\multi.c(845): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(845): error C2037: left of ‘fd’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(846): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(846): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(851): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(851): error C2037: left of ‘fd’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(852): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(852): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(867): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(867): error C2037: left of ‘fd’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(868): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(868): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(870): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(870): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(872): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(872): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(874): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(874): error C2037: left of ‘events’ specifies undefined struct/union ‘pollfd’
1>lib\multi.c(890): error C2036: ‘pollfd *’ : unknown size
1>lib\multi.c(890): error C2037: left of ‘revents’ specifies undefined struct/union ‘pollfd’
there is a solution?
Thanks!!!