-
-
Notifications
You must be signed in to change notification settings - Fork 997
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
WIP: add callbacks to alerts (should I continue?) #7557
base: RC_2_0
Are you sure you want to change the base?
Conversation
a simple example: std::mutex m;
std::condition_variable cv;
bool done = false;
th.flush_cache([&cv, &done] (const lt::cache_flushed_alert* alert) {
// here you are in the libtorrent network thread
done = true;
cv.notify_one();
});
{
std::unique_lock lk(m);
while (!done) cv.wait(lk);
}
|
76e4ff4
to
51db89b
Compare
For me, it doesn't look too useful to use callbacks to get some requested data from libtorrent, which will simply be used in another thread (existing alerts will also be quite suitable here). |
looks like you want to use a torrent_plugin ? my proposal is based on the fact that without a similar modification on the client side (at the level of torrent_handle or session_handle) you cannot identify which alerts correspond to which calls. |
I have to use libtorrent extensions feature ( |
Agree. It makes sense in case when some alert is reaction to user requested action. |
like a |
Something like |
0505943
to
79858f5
Compare
That would be a super interesting feature to simplify the coding workflow by writing logic "where you need it and where you understand the need" (and without having to create a new extension) |
79858f5
to
5bae950
Compare
5bae950
to
8200eaa
Compare
this pull request allows you to have a callback (which will be executed on the libtorrent thread when the alert is set in the queue) on asynchronous methods that trigger alerts:
torrent_handle:
session_handle: