I loved the talk. Especially the very nice and enlightning story. That said, I find fairly confusing the way read/write operations are tasks that you enqueue and are each executed once, and lead to this weird "recursive enqueueing" pattern, that I personally find error prone, and quite unintuitive with added issues like lifetimes management problems. Maybe I'm juste naive, but when I think of a server, I just want to have a callback when something have been read (and the server reads continuously without me doing anything about this), and have a write() operation, that may be asynchronous.
You can totally do that. But in that architecture you would need something to manage lifetime of one connection (socket in the handler). By using shared_ptr and enable_shared_from_this you can hide that management layer. It's neat :)
I know right?! I'm trying to implement asio with a little home built audio synth. But I'm still quite a novice and not sure where to start. I have a situation where the synth produces at a certain rate, and the endpoint consumes at a certain rate that do not match.... I'd like to take advantage of free time during endpoint's buffer consumption to produce more sound w/FX processing etc...
@@kb3khs First, create an abstract model of program/data flow independent of your programming language/libraries. Then, start with C and do some small experiments with read()/write(),epoll() calls and maybe threads to get an overview how things work under the hood and how asio is different from sync. io/threads with locks. Then you can go back at your abstract design and decide if you want to go for asio or something different.
The way he his storing the object in a shared pointer and keeping that in a lambda may be a memory leak. Unless you reset the shared pointer in the lambda body it will not get destroyed as a member variable and keep the object alive? Am I missing something?
This the following are semantically equivalent: template void foo(Ts ... ts){} void foo(auto ... ts){} However, until C++20, it wasn't possible to write lamdbas with templated parameters, and so the rather unorthodox auto... syntax was used instead. Note how that I could get this behavior like follows: auto fn = [](Ts... vs) {};
I am lookin for async_connect implementation with strands. If you call async_connect and immediatelly try to write, the way to force connect_handle earlier than the write error is quite not obvious...
They are linked in the comments, indirectly, github.com/CppCon/CppCon2016/blob/master/Tutorials/Asynchronous%20IO%20with%20Boost.Asio/Asynchronous%20IO%20with%20Boost.Asio%20-%20Michael%20Caisse%20-%20CppCon%202016.pdf
Best Cppcon 2016 talk. Useful stuff and tips. ASIO and coroutines, state machines and Spirit all deserve their own talk, maybe next year?
I loved the talk. Especially the very nice and enlightning story.
That said, I find fairly confusing the way read/write operations are tasks that you enqueue and are each executed once, and lead to this weird "recursive enqueueing" pattern, that I personally find error prone, and quite unintuitive with added issues like lifetimes management problems.
Maybe I'm juste naive, but when I think of a server, I just want to have a callback when something have been read (and the server reads continuously without me doing anything about this), and have a write() operation, that may be asynchronous.
nope. same here. (but i just know a few c++).
great story to illustrate the concepts. then c++ code ruined the story lol : )
You can totally do that. But in that architecture you would need something to manage lifetime of one connection (socket in the handler). By using shared_ptr and enable_shared_from_this you can hide that management layer. It's neat :)
I want that Asio+MSM+Spirit talk , please ! :)
Great lecture. I wish I watched it few years ago instead of going thru the docs.
It is getting on my nerves that every ASIO example out there is showcasing a TCP server. Is there nothing else people do with ASIO?
Indeed.
I know right?! I'm trying to implement asio with a little home built audio synth. But I'm still quite a novice and not sure where to start. I have a situation where the synth produces at a certain rate, and the endpoint consumes at a certain rate that do not match.... I'd like to take advantage of free time during endpoint's buffer consumption to produce more sound w/FX processing etc...
@@kb3khs First, create an abstract model of program/data flow independent of your programming language/libraries. Then, start with C and do some small experiments with read()/write(),epoll() calls and maybe threads to get an overview how things work under the hood and how asio is different from sync. io/threads with locks.
Then you can go back at your abstract design and decide if you want to go for asio or something different.
JC! Isn't Asio enough complicated to complicate it even more with butlers and family?
The way he his storing the object in a shared pointer and keeping that in a lambda may be a memory leak.
Unless you reset the shared pointer in the lambda body it will not get destroyed as a member variable and keep the object alive?
Am I missing something?
What is `auto ... vn` in the lambda arguments?
This the following are semantically equivalent:
template
void foo(Ts ... ts){}
void foo(auto ... ts){}
However, until C++20, it wasn't possible to write lamdbas with templated parameters, and so the rather unorthodox auto... syntax was used instead. Note how that I could get this behavior like follows:
auto fn = [](Ts... vs)
{};
I am lookin for async_connect implementation with strands. If you call async_connect and immediatelly try to write, the way to force connect_handle earlier than the write error is quite not obvious...
loved the talk
Great info but all this it would be easier to explain with shapes and arrows...
Can we access the slides somewhere?
They are linked in the comments, indirectly, github.com/CppCon/CppCon2016/blob/master/Tutorials/Asynchronous%20IO%20with%20Boost.Asio/Asynchronous%20IO%20with%20Boost.Asio%20-%20Michael%20Caisse%20-%20CppCon%202016.pdf
Great talk as expected, but the lambda at 58:19 is by far the ugliest rendition of code I have seen in a long time.
Anybody knows how to use boost::asio just only to poll list of file descriptor ??
What about file async i/o in POSIX?
You wouldn't do it with ASIO. You can do it the exact same way you do it in C.
amazing how geeks can tell really good jokes about slushies and butters but still keep a very straight face!