Add channel method to fetchers and senders.
This makes it easy to figure out which channel a fetcher or sender
is connected to.
Also add a test to confirm that the channel pointer points to a channel
inside configuration() for the event loop.
Change-Id: Iee0edca66394ef825dac482d7e3f568c6ed3441f
diff --git a/aos/events/shm_event_loop.cc b/aos/events/shm_event_loop.cc
index 5a88717..7506954 100644
--- a/aos/events/shm_event_loop.cc
+++ b/aos/events/shm_event_loop.cc
@@ -144,7 +144,8 @@
class ShmFetcher : public RawFetcher {
public:
explicit ShmFetcher(const Channel *channel)
- : lockless_queue_memory_(channel),
+ : RawFetcher(channel),
+ lockless_queue_memory_(channel),
lockless_queue_(lockless_queue_memory_.memory(),
lockless_queue_memory_.config()),
data_storage_(static_cast<AlignedChar *>(aligned_alloc(
@@ -273,7 +274,7 @@
class ShmSender : public RawSender {
public:
explicit ShmSender(const Channel *channel, const ShmEventLoop *shm_event_loop)
- : RawSender(),
+ : RawSender(channel),
shm_event_loop_(shm_event_loop),
name_(channel->name()->str()),
lockless_queue_memory_(channel),
@@ -449,11 +450,13 @@
::std::unique_ptr<RawFetcher> ShmEventLoop::MakeRawFetcher(
const Channel *channel) {
+ ValidateChannel(channel);
return ::std::unique_ptr<RawFetcher>(new ShmFetcher(channel));
}
::std::unique_ptr<RawSender> ShmEventLoop::MakeRawSender(
const Channel *channel) {
+ ValidateChannel(channel);
Take(channel);
return ::std::unique_ptr<RawSender>(new ShmSender(channel, this));
}
@@ -461,6 +464,7 @@
void ShmEventLoop::MakeRawWatcher(
const Channel *channel,
std::function<void(const Context &context, const void *message)> watcher) {
+ ValidateChannel(channel);
Take(channel);
::std::unique_ptr<internal::WatcherState> state(