Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WinRT ThreadEmulation for Threading on WinRT #1

Open
stammen opened this issue Jan 26, 2014 · 7 comments
Open

Use WinRT ThreadEmulation for Threading on WinRT #1

stammen opened this issue Jan 26, 2014 · 7 comments

Comments

@stammen
Copy link

stammen commented Jan 26, 2014

http://blogs.msdn.com/b/shawnhar/archive/2012/03/12/createthread-for-windows-8-metro.aspx

Supports CreateThread(). I have used it in other projects.

@martell
Copy link
Owner

martell commented Jan 26, 2014

I can't use c++ code in libcurl as it will give hundreds of errors
I'll try and put it in winrtsock and export it.
That way libwebsockets can use it later.

We may want to look at the wrapper the mingw-w64 project has for some functions?

@stammen
Copy link
Author

stammen commented Jan 26, 2014

You just need to write a c wrapper to the cpp code. Something similar to

http://blog.eikke.com/index.php/ikke/2005/11/03/using_c_classes_in_c.html

Since you are only dealing with a HANDLE returned by ThreadEmulation and simple Primitive data types (BOOL, VOID, DWORD), the C wrapper should be pretty simple.

@martell
Copy link
Owner

martell commented Jan 26, 2014

Ahh I see. I was looking at the VLC port and they do something similar. Thanks Dale this seems doable now

@martell
Copy link
Owner

martell commented Jan 26, 2014

2>asyn-thread.obj : error LNK2001: unresolved external symbol _InitializeCriticalSectionEx
2>connect.obj : error LNK2001: unresolved external symbol _CreateEventEx
2>curl_threads.obj : error LNK2001: unresolved external symbol __beginthreadex
2>timeval.obj : error LNK2001: unresolved external symbol _GetModuleHandleW

Down to 4 errors now. May need input on the winrtsock SO_KEEPALIVEFLAG
Will resolve these 4 first

@stammen
Copy link
Author

stammen commented Jan 26, 2014

FYI GetModuleHandle(W)(Ex) is not supported on WinRT

On WinRT you should use LoadPackagedLibrary to load a DLL and GetProcAddress to get the function. Look at

https://github.com/stammen/angleproject/blob/dev/src/libGLESv2/renderer/Renderer.cpp for an example

@martell
Copy link
Owner

martell commented Jan 26, 2014

Okay I've fixed all the errors, what happens is if you #include from a c file instead of a cpp file you don't get half he windows api on rt because a #define win32_rt doesn't get defined. I just prototyped the functions needed. It feels like MS headers are trying and force you to use c++ :/ Anyway this is now solved.

I didn't need GetModuleHandle in the end :)

We now have a dll and I have merged it in to cocos2d-x. I'll make a new pull request with WinRT support.

I may chaned the thread emulation to what you have above because it crashes.
Then the last thing I have to do is add the KEEP ALIVE code in winsockrt.

Not quite sure how to add this but it should at least link on winrt and cocos2d-x for now :)

@martell
Copy link
Owner

martell commented Jan 26, 2014

Note cocos2d/cocos2d-x#5247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants