OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librlink/] [ReventLoop.hpp] - Blame information for rev 36

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 wfjm
// $Id: ReventLoop.hpp 662 2015-04-05 08:02:54Z mueller $
2 19 wfjm
//
3 30 wfjm
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 19 wfjm
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 30 wfjm
// 2015-04-04   662   1.2    BUGFIX: fix race in Stop(), add UnStop,StopPending
17 21 wfjm
// 2013-05-01   513   1.1.1  fTraceLevel now uint32_t
18 19 wfjm
// 2013-02-22   491   1.1    use new RlogFile/RlogMsg interfaces
19
// 2013-01-11   473   1.0    Initial version
20
// ---------------------------------------------------------------------------
21
 
22
 
23
/*!
24
  \file
25 30 wfjm
  \version $Id: ReventLoop.hpp 662 2015-04-05 08:02:54Z mueller $
26 19 wfjm
  \brief   Declaration of class \c ReventLoop.
27
*/
28
 
29
#ifndef included_Retro_ReventLoop
30
#define included_Retro_ReventLoop 1
31
 
32
#include <poll.h>
33
 
34
#include <cstdint>
35
#include <vector>
36
 
37
#include "boost/utility.hpp"
38
#include "boost/function.hpp"
39
#include "boost/thread/mutex.hpp"
40
#include "boost/shared_ptr.hpp"
41
 
42
#include "librtools/RlogFile.hpp"
43
 
44
namespace Retro {
45
 
46
  class ReventLoop : private boost::noncopyable {
47
    public:
48
      typedef boost::function<int(const pollfd&)> pollhdl_t;
49
 
50
                    ReventLoop();
51
      virtual      ~ReventLoop();
52
 
53
      void          AddPollHandler(const pollhdl_t& pollhdl,
54
                               int fd, short events=POLLIN);
55
      bool          TestPollHandler(int fd, short events=POLLIN);
56
      void          RemovePollHandler(int fd, short events, bool nothrow=false);
57
      void          RemovePollHandler(int fd);
58
 
59
      void          SetLogFile(const boost::shared_ptr<RlogFile>& splog);
60 21 wfjm
      void          SetTraceLevel(uint32_t level);
61
      uint32_t      TraceLevel() const;
62 19 wfjm
 
63
      void          Stop();
64 30 wfjm
      void          UnStop();
65
      bool          StopPending();
66 19 wfjm
      virtual void  EventLoop();
67
 
68
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
69
 
70
    protected:
71
 
72
      int           DoPoll(int timeout=-1);
73
      void          DoCall(void);
74
 
75
    protected:
76
 
77
      struct PollDsc {
78
        pollhdl_t   fHandler;
79
        int         fFd;
80
        short       fEvents;
81
        PollDsc(pollhdl_t hdl,int fd,short evts) :
82
          fHandler(hdl),fFd(fd),fEvents(evts)  {}
83
      };
84
 
85 30 wfjm
      bool          fStopPending;
86 19 wfjm
      bool          fUpdatePoll;
87
      boost::mutex  fPollDscMutex;
88
      std::vector<PollDsc>   fPollDsc;
89
      std::vector<pollfd>    fPollFd;
90
      std::vector<pollhdl_t> fPollHdl;
91 21 wfjm
      uint32_t      fTraceLevel;            //!< trace level
92 19 wfjm
      boost::shared_ptr<RlogFile>  fspLog;  //!< log file ptr
93
};
94
 
95
} // end namespace Retro
96
 
97
#include "ReventLoop.ipp"
98
 
99
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.