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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 21 wfjm
// $Id: ReventLoop.hpp 513 2013-05-01 14:02:06Z mueller $
2 19 wfjm
//
3
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
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 21 wfjm
// 2013-05-01   513   1.1.1  fTraceLevel now uint32_t
17 19 wfjm
// 2013-02-22   491   1.1    use new RlogFile/RlogMsg interfaces
18
// 2013-01-11   473   1.0    Initial version
19
// ---------------------------------------------------------------------------
20
 
21
 
22
/*!
23
  \file
24 21 wfjm
  \version $Id: ReventLoop.hpp 513 2013-05-01 14:02:06Z mueller $
25 19 wfjm
  \brief   Declaration of class \c ReventLoop.
26
*/
27
 
28
#ifndef included_Retro_ReventLoop
29
#define included_Retro_ReventLoop 1
30
 
31
#include <poll.h>
32
 
33
#include <cstdint>
34
#include <vector>
35
 
36
#include "boost/utility.hpp"
37
#include "boost/function.hpp"
38
#include "boost/thread/mutex.hpp"
39
#include "boost/shared_ptr.hpp"
40
 
41
#include "librtools/RlogFile.hpp"
42
 
43
namespace Retro {
44
 
45
  class ReventLoop : private boost::noncopyable {
46
    public:
47
      typedef boost::function<int(const pollfd&)> pollhdl_t;
48
 
49
                    ReventLoop();
50
      virtual      ~ReventLoop();
51
 
52
      void          AddPollHandler(const pollhdl_t& pollhdl,
53
                               int fd, short events=POLLIN);
54
      bool          TestPollHandler(int fd, short events=POLLIN);
55
      void          RemovePollHandler(int fd, short events, bool nothrow=false);
56
      void          RemovePollHandler(int fd);
57
 
58
      void          SetLogFile(const boost::shared_ptr<RlogFile>& splog);
59 21 wfjm
      void          SetTraceLevel(uint32_t level);
60
      uint32_t      TraceLevel() const;
61 19 wfjm
 
62
      void          Stop();
63
      virtual void  EventLoop();
64
 
65
      virtual void  Dump(std::ostream& os, int ind=0, const char* text=0) const;
66
 
67
    protected:
68
 
69
      int           DoPoll(int timeout=-1);
70
      void          DoCall(void);
71
 
72
    protected:
73
 
74
      struct PollDsc {
75
        pollhdl_t   fHandler;
76
        int         fFd;
77
        short       fEvents;
78
        PollDsc(pollhdl_t hdl,int fd,short evts) :
79
          fHandler(hdl),fFd(fd),fEvents(evts)  {}
80
      };
81
 
82
      bool          fLoopActive;
83
      bool          fUpdatePoll;
84
      boost::mutex  fPollDscMutex;
85
      std::vector<PollDsc>   fPollDsc;
86
      std::vector<pollfd>    fPollFd;
87
      std::vector<pollhdl_t> fPollHdl;
88 21 wfjm
      uint32_t      fTraceLevel;            //!< trace level
89 19 wfjm
      boost::shared_ptr<RlogFile>  fspLog;  //!< log file ptr
90
};
91
 
92
} // end namespace Retro
93
 
94
#include "ReventLoop.ipp"
95
 
96
#endif

powered by: WebSVN 2.1.0

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