-
Notifications
You must be signed in to change notification settings - Fork 29
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
Replace pthread with CThreads #141
base: dev
Are you sure you want to change the base?
Conversation
9ec25be
to
7796fdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very promising, good progress so far. I've left a couple questions and suggestions regarding the implementation, but mostly nitpicks!
src/discord-voice.c
Outdated
@@ -643,6 +643,8 @@ discord_voice_join(struct discord *client, | |||
bool self_mute, | |||
bool self_deaf) | |||
{ | |||
client_lock = __cthreads_mutex_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure about this one.. does Windows have a PTHREAD_MUTEX_INITIALIZER equivalent? You can try searching for "initializing global mutex Windows"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I have seen no, according to this stack overflow answer
I wonder if you really need it, because if yes we can check if it exists in every cthreads action, so it will work anyways, but for using voice they will first use that one anyways, are they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's a ton of work to replace those ifdefs, but, I feel it may be a better idea to use osname
in lieu of #else
, since that feels like a "solution of last resort."
e024684
to
bb1386f
Compare
Woah! That was... insane, well, I've applied the suggestions I've understood and fixed some errors and improved the functions, it should be better now.. although I need to test it on Windows.. I'm going to do later since now I'm a little tired for testing, but should work on Linux |
bb1386f
to
7dad488
Compare
I've got some bugs fixed (mainly on Windows threads but also on pthreads), now pthread is working fine, although I'm still dealing with cygwin "exception" with pthread & windows threads, I'm going to try to use MSYS2 and see if it works (It didn't work, it still uses cygwin for some wild reason) |
I'm going to check the ones I didn't really solve in the reviews soonly, but is anybody available to test it? I got it working on cygwin (manually removing the ifdefs to get the windows.h since for some reasons it doesn't set win flag) and should work on the rest |
8955e85
to
ea13c56
Compare
c2345fc
to
c717805
Compare
Okay, time for my Official Review of Cthreads: TESTED COMPILERS:
Works on all of those. There is only one issue, and, that's the dilemma of a warning that you get on line 72 of Also, I should mention that this is a test of compiling and linking Cthreads, NOT all of Concord! |
b318f52
to
51b3073
Compare
I've fixed some issues (in both pthread and Windows threads), but I'm still going to take a look in the Windows equivalents to be sure everything's alright Tests are appreciated, but most things are the same, should still work |
CThreads can also work in Windows using Windows threads, due to this, pthread was replaced by it. Co-authored-by: Lucas Müller <[email protected]> Co-authored-by: HackerSmacker <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a minute, but, I think it should be good. All the tests I've done were good, so, I think it's good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but we should merge this once the TLS issue is sorted out
ccb44d1
to
50c8f29
Compare
This commit updates CThreads library with latest fixes.
50c8f29
to
61e9dc0
Compare
f88f90d
to
033bdc9
Compare
I've looked though the code, it's not fully featured, and contains some serious flaws. If you want to support windows threads, I'd look into something such as this https://github.com/GerHobbelt/pthread-win32 first. |
Thanks for the review! Could you provide me the list of the flaws? I took a small look on pthread-win32, but I don't think it follows CThreads goals: uncomplicated "threading library", allowing cross-compatibility while having a small and easy (lib) codebase About not being fully featured, CThreads was born to be for Concord primarily, and it covers all used pthread functions. I do plan to cover more parts Thanks for the patience to review anyway |
This commit improves CThreads usage by destroying properly the mutexes, and expanding its usage to examples.
033bdc9
to
cafb3ff
Compare
8c9569f
to
ef13fba
Compare
This commit updates the library, allowing it to work properly on Windows.
I was able to get back to my city where I have a Windows machine and fix Windows part issues. Now, with proper edits to make Cygwin to use Windows part, it works flawlessly |
To give you a little update on this, we will need to hold until we have an actual structure for unit testing, integration tests, e2e tests. Otherwise, its a bit too risky to merge on the repo's current state |
Notice
to test it before making changes to Concord.
What?
This PR replaces the pthread by cthread (a library that uses both pthread and Windows Threads).
Why?
To improve compability with native Windows, and to not be necessary to use pthread on Windows.
How?
All parts where pthread is used, was replaced with cthreads functions.
Testing?
Basic testing using Concord's testing was used, on Windows and Linux (Arch Linux), but more testings must be done.