1// excerpts from http://code.google.com/p/muduo/
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the License file.
5//
6// Author: Shuo Chen (chenshuo at chenshuo dot com)
7
8#ifndef MUDUO_NET_EVENTLOOP_H
9#define MUDUO_NET_EVENTLOOP_H
10
11#include "thread/Thread.h"
12
13namespace muduo
14{
15
16class EventLoop : boost::noncopyable
17{
18 public:
19
20  EventLoop();
21  ~EventLoop();
22
23  void loop();
24
25  void assertInLoopThread()
26  {
27    if (!isInLoopThread())
28    {
29      abortNotInLoopThread();
30    }
31  }
32
33  bool isInLoopThread() const { return threadId_ == CurrentThread::tid(); }
34
35 private:
36
37  void abortNotInLoopThread();
38
39  bool looping_; /* atomic */
40  const pid_t threadId_;
41};
42
43}
44
45#endif  // MUDUO_NET_EVENTLOOP_H
46