-
Notifications
You must be signed in to change notification settings - Fork 291
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
Toxcore and thread safe (question) #854
Comments
Toxcore is not thread-safe, you must synchronize all access to it. You can safely access it in-between The documentation has some explanation on thread-safety but it somehow misses to tell all this. |
Well, the logic is clear. But there is the following question: it turns out that toxav instance has to live in the same thread, as tox, because the toxav functions is directly address to tox data fields without any blocking. For example: toxav_answer() -> m_friend_exists(). |
Sorry, not familiar with toxav, maybe someone else can answer this. |
See documentation in toxav.h
|
Yes, I read this. But let's look inside the function, for example:
@dvor, you think that calling m_friend_exists(av-> m, friend_number) is thread-safe?
Here I would also like to understand: maybe I don't see some moments, and my fears are vain. |
@hkarel some more info to threading and AV: |
@zoff99, judging by the code, the toxav data is protected from race conditions, but for tox the probability of race conditions is present, see the code example above. By the way, in your example the function toxav_audio_send_frame() call is shown. |
I agree with @hkarel's concerns here, this |
for these cases making |
In my project, I solved this problem as follows:
At the tox-core thread loop
Inside tox-callback functions the ToxGlobalLock locker not used. |
Toxcore is not aiming to be thread-safe. You can use a lock outside toxcore to lock the whole Tox instance. |
In my application the toxcore worked in a separate thread. Whether it will be safe to call functions (for example tox_friend_by_public_key()) to work with the toxcore from another thread?
The text was updated successfully, but these errors were encountered: