How thread safe are promises?
See original GitHub issueAfter reading through the source for some time I do not see any use of locks (like the imported and ignored from threading import RLock
) to protect one thread adding a callback to a promise instance from another thread that is resolving/rejecting that promise…
So is such use of a promise invalid or does it work because of the GIL? … or something else?
Thanks for the awesome code!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Is std::promise<T> thread-safe? - c++ - Stack Overflow
1. So calling get_future from multiple threads doesn't really make sense from a practical point of view. There is no guarantee for thread-safety...
Read more >Is Combine Future's promise thread… | Apple Developer Forums
Yes, Future is thread safe. Escaping parameters like that out of a block might result easily in leaks, but should still work. Posted...
Read more >std::promise - cppreference.com
This example shows how promise<int> can be used as signals between threads. Run this code. #include <vector> #include <thread> #include <future> ...
Read more >A thread-safe typed Promise implementation in Java for Android
I've created a typed Promise implementation in Java for Android, borrowing ideas from this article for a JavaScript implementation, by Forbes ...
Read more >Multithreading in C++ - Modern C++ Concurrency - Educative.io
Tasks are like data channels between two communication endpoints. They enable thread-safe communication between threads: the promise at one endpoint puts data ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@PepperTeasdale It sounds like your issue is related to https://github.com/syrusakbary/promise/issues/57
The PR #81 has been merged. Promises should be now thread-safe in Promise 2.3.0