-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Seastar Tutorial Future Topics
This is a list of future topics for upcoming chapters of the Seastar Tutorial.
We already saw chaining example in slow() in the first part of the tutorial. talk about the return from then, and returning a future and chaning more thens.
Mention the event loop (scheduler). remind that continuations on the same thread do not run in parallel, so do not need locks, atomic variables, etc (different threads shouldn't access the same data - more on that below). continuations obviously must not use blocking operations, or they block the whole thread.
Talk about polling that we currently do, and how today even sleep() or waiting for incoming connections or whatever, takes 100% of all CPUs.
Mention that our main mode of operation is to take a L2 (Ethernet) interface (vhost or dpdk) and on top of it we built (in Seastar itself) an L3 interface (TCP/IP). Start to give examples of connect, read, write, temporary-buffer, etc.
About how useful lw_shared_ptr is for capture.
handle SIGUSR1 pass noprint handle SIGALRM pass noprint
As we already defined above, An asynchronous function, also called a promise, is a function or object which returns a future and arranges for this future to be eventually resolved. As we already saw, an asynchronous function is usually written in terms of other asynchronous functions, for example we saw the function slow()
which waits for the existing asynchronous function sleep()
to complete, and then returns 3:
future<int> slow() {
using namespace std::chrono_literals;
return sleep(100ms).then([] { return 3; });
}
The most basic building block for writing promises is the promise object, an object of type promise<T>
. A promise<T>
has a method future<T> get_future()
to returns a future, and a method set_value(T)
, so resolve this future. An asynchronous function can create a promise object, return its future, and the set_value
method to be eventually called - which will finally resolve the future it returned.
CONTINUE HERE. write an example, e.g., something which writes a message every second, and after 10 messages, completes the future.