Commit Graph

6 Commits

Author SHA1 Message Date
Avi Kivity
9243187ac2 stream: make subscriptions a little more usable
Requiring next_fn to be available at listen() time means you can't pass
subscriptions around, and it is often hard to create next_fn, since it
usually needs to capture 'this', while this also points to the subscription
itself, creating a chicken and egg problem.

Fix by separating the registration process into two steps: listen() creates
the subscription, and start() accepts the next callback and starts processing
events.
2015-05-28 13:11:40 +03:00
Avi Kivity
7f8d88371a Add LICENSE, NOTICE, and copyright headers to all source files.
The two files imported from the OSv project retain their original licenses.
2015-02-19 16:52:34 +02:00
Avi Kivity
381814aeaf stream.hh: add missing include 2015-02-10 18:59:38 +02:00
Avi Kivity
8101c1f2a6 stream/subscription: fix build error in stream::close() 2015-01-07 15:12:23 +02:00
Gleb Natapov
2fb7490bf9 stream: reset subscription's stream pointer in stream's destructor 2014-12-30 15:21:08 +02:00
Avi Kivity
af1c015526 core: add stream/subscription abstraction
The future/promise pair is for single-shot use only, which makes it
less useful for repetitive processing.

Add a stream/subscription abstraction, where a stream can produce data
which is repetitively consumed by the subscription.  End-or-stream (or
error condition) is provided by a future.

Inspired by Dart's Stream class.
2014-09-22 11:25:54 +03:00