#ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
#define MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
#include "mojo/public/cpp/system/core.h"
namespace mojo {
class MessageReceiver;
bool WaitForMessageAndDispatch(MessagePipeHandle handle,
mojo::MessageReceiver* receiver);
template<typename S> class SyncDispatcher {
public:
SyncDispatcher(ScopedMessagePipeHandle message_pipe, S* sink)
: message_pipe_(message_pipe.Pass()),
stub_(sink) {
}
bool WaitAndDispatchOneMessage() {
return WaitForMessageAndDispatch(message_pipe_.get(), &stub_);
}
private:
ScopedMessagePipeHandle message_pipe_;
typename S::_Stub stub_;
};
}
#endif