10#ifndef BIDIRMMAPPIPE_H 
   11#define BIDIRMMAPPIPE_H 
   20#define BEGIN_NAMESPACE_ROOFIT namespace RooFit { 
   21#define END_NAMESPACE_ROOFIT } 
   26namespace BidirMMapPipe_impl {
 
   28    class BidirMMapPipeException;
 
   75            static unsigned getPageSize();
 
   78            static void* dommap(
unsigned len);
 
   80            static void domunmap(
void* 
p, 
unsigned len);
 
   87            static unsigned pagesize() { 
return s_pagesize; }
 
   89            static unsigned physPgSz() { 
return s_physpgsz; }
 
  100            bool contains(
const Pages& 
p) 
const;
 
  106            void push(
const Pages& 
p);
 
  111                return reinterpret_cast<unsigned char*
>(m_end) -
 
  112                    reinterpret_cast<unsigned char*
>(m_begin);
 
  118            bool empty()
 const { 
return !m_nUsedGrp; }
 
  121            bool full()
 const { 
return m_freelist.empty(); }
 
  165            static unsigned pagesize();
 
  168            unsigned npages()
 const { 
return m_pimpl->m_npages; }
 
  171            Page* page(
unsigned pgno) 
const;
 
  177            unsigned pageno(
Page* 
p) 
const;
 
  393            badbit = rderrbit | wrerrbit, 
 
  421        BidirMMapPipe(
bool useExceptions = 
true, 
bool useSocketpair = 
false);
 
  450        size_type read(
void* addr, size_type sz);
 
  463        size_type write(
const void* addr, size_type sz);
 
  483        size_type bytesReadableNonBlocking();
 
  489        size_type bytesWritableNonBlocking();
 
  505        { 
return isChild() ? m_parentPid : m_childPid; }
 
  517            EndOfFile = ReadEndOfFile | WriteEndOfFile, 
 
  520            Invalid = ReadInvalid | WriteInvalid 
 
  531                    pipe(_pipe), events(
None), revents(
None) { }
 
  534                    pipe(_pipe), events(_events), revents(
None) { }
 
  677        static int poll(
PollVector& pipes, 
int timeout);
 
  713        bool eof()
 const { 
return m_flags & eofbit; }
 
  719        bool fail()
 const { 
return m_flags & failbit; }
 
  725        bool bad()
 const { 
return m_flags & badbit; }
 
  731        bool good()
 const { 
return !(m_flags & (eofbit | failbit | badbit)); }
 
  737        bool closed()
 const { 
return m_flags & failbit; }
 
  745        operator bool()
 const { 
return !fail() && !bad(); }
 
  756#define STREAMOP(TYPE) \ 
  757        BidirMMapPipe& operator<<(const TYPE& val) \ 
  758        { write(&val, sizeof(TYPE)); return *this; } \ 
  759        BidirMMapPipe& operator>>(TYPE& val) \ 
  760        { read(&val, sizeof(TYPE)); return *this; } 
  817        { write(&tptr, 
sizeof(tptr)); 
return *
this; }
 
  828        { read(&tptr, 
sizeof(tptr)); 
return *
this; }
 
  841        { 
return manip(*
this); }
 
  854        { 
return manip(*
this); }
 
  879            PagesPerEnd = TotPages / 2, 
 
  883            FlushThresh = (3 * PagesPerEnd) / 4 
 
  912        static void teardownall(
void);
 
  915        static unsigned lenPageList(
const Page* list);
 
  925        void feedPageLists(
Page* plist);
 
  928        void markPageDirty(
Page* 
p);
 
  932                ssize_t (*xferfn)(
int, 
void*, std::size_t));
 
  935                ssize_t (*xferfn)(
int, 
const void*, std::size_t))
 
  937            return xferraw(fd, addr, 
len,
 
  938                    reinterpret_cast<ssize_t (*)(
 
  939                        int, 
void*, std::size_t)
>(xferfn));
 
  952        void sendpages(Page* plist);
 
  964        unsigned recvpages();
 
  973        unsigned recvpages_nonblock();
 
  981        int doClose(
bool force, 
bool holdlock = 
false);
 
  983        void doFlush(
bool forcePartialPages = 
true);
 
  989#undef BEGIN_NAMESPACE_ROOFIT 
  990#undef END_NAMESPACE_ROOFIT 
#define END_NAMESPACE_ROOFIT
 
#define BEGIN_NAMESPACE_ROOFIT
 
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
 
TBuffer & operator>>(TBuffer &buf, Tmpl *&obj)
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
 
winID h TVirtualViewer3D TVirtualGLPainter p
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
 
Binding & operator=(OUT(*fun)(void))
 
unsigned events
events of interest (or'ed bitmask)
 
unsigned revents
events that happened (or'ed bitmask)
 
PollEntry(BidirMMapPipe *_pipe)
poll a pipe for all events
 
PollEntry(BidirMMapPipe *_pipe, int _events)
poll a pipe for specified events
 
BidirMMapPipe * pipe
pipe of interest
 
exception to throw if low-level OS calls go wrong
 
class representing a chunk of pages
 
BidirMMapPipeException Exception
convenience typedef
 
std::list< void * > m_freelist
free pages list
 
void * m_end
pointer one behind end of mmapped area
 
void * m_begin
pointer to start of mmapped area
 
MMapVariety
type of mmap support found
 
@ FileBacked
mmapping a temp file works
 
@ Unknown
don't know yet what'll work
 
@ DevZero
mmapping /dev/zero works
 
@ Copy
mmap doesn't work, have to copy back and forth
 
static unsigned pagesize()
return the logical page size
 
PagePool * m_parent
parent page pool
 
unsigned m_nUsedGrp
number of used page groups
 
static MMapVariety s_mmapworks
mmap variety that works on this system
 
static unsigned s_physpgsz
system physical page size
 
static MMapVariety mmapVariety()
return mmap variety support found
 
unsigned m_nPgPerGrp
number of pages per group
 
static unsigned physPgSz()
return the physical page size of the system
 
static unsigned s_pagesize
logical page size (run-time determined)
 
unsigned len() const
return length of chunk
 
PageChunk(const PageChunk &)
forbid copying
 
bool full() const
return true if no free page groups in this chunk
 
PageChunk & operator=(const PageChunk &)
forbid assignment
 
unsigned nPagesPerGroup() const
return number of pages per page group
 
bool empty() const
return true if no used page groups in this chunk
 
class representing a page pool
 
class representing the header structure in an mmapped page
 
handle class for a number of Pages
 
unsigned npages() const
return number of pages accessible
 
Page * operator[](unsigned pgno) const
return page number pageno
 
impl * m_pimpl
pointer to implementation
 
unsigned operator[](Page *p) const
perform page to page number mapping
 
void swap(Pages &other)
swap with other's contents
 
Pages()
default constructor
 
BidirMMapPipe creates a bidirectional channel between the current process and a child it forks.
 
std::vector< PollEntry > PollVector
convenience typedef for poll() interface
 
Page * m_busylist
linked list: busy pages (data to be read)
 
BidirMMapPipe_impl::BidirMMapPipeException Exception
convenience typedef for BidirMMapPipeException
 
BidirMMapPipe_impl::Pages m_pages
mmapped pages
 
void flush()
flush buffers with unwritten data
 
static BidirMMapPipe_impl::PagePool * s_pagepool
pool of mmapped pages
 
BidirMMapPipe_impl::Page Page
convenience typedef for Page
 
bool good() const
status of stream is good
 
bool isChild() const
return if this end of the pipe is the child end
 
bool eof() const
true if end-of-file
 
static std::list< BidirMMapPipe * > s_openpipes
list of open BidirMMapPipes
 
pid_t pidOtherEnd() const
return PID of the process on the other end of the pipe
 
int m_flags
flags (e.g. end of file)
 
bool fail() const
logical failure (e.g.
 
bool usesPipepair() const
if BidirMMapPipe uses a pipe pair for communications
 
bool bad() const
true on I/O error
 
BidirMMapPipe & operator=(const BidirMMapPipe &)
assignment forbidden
 
bool usesSocketpair() const
if BidirMMapPipe uses a socketpair for communications
 
bool closed() const
true if closed
 
static BidirMMapPipe & purge(BidirMMapPipe &pipe)
for usage a la "pipe << purge;"
 
int m_inpipe
pipe end from which data may be read
 
BidirMMapPipe & operator<<(BidirMMapPipe &(*manip)(BidirMMapPipe &))
I/O manipulator support.
 
int rdstate() const
return flags (end of file, BidirMMapPipe closed, ...)
 
static unsigned s_pagepoolrefcnt
page pool reference counter
 
Page * m_dirtylist
linked list: dirty pages (data to be sent)
 
bool isParent() const
return if this end of the pipe is the parent end
 
static pthread_mutex_t s_openpipesmutex
protects s_openpipes
 
PollFlags
condition flags for poll
 
bool operator!() const
return true if serious error (fail/bad)
 
static int debugflag()
return the current setting of the debug flag
 
void purge()
purge buffered data waiting to be read and/or written
 
pid_t m_parentPid
pid of the parent
 
static size_type xferraw(int fd, void *addr, const size_type len, ssize_t(*xferfn)(int, const void *, std::size_t))
transfer bytes through the pipe (reading, writing, may block)
 
BidirMMapPipe & operator>>(T *&tptr)
read raw pointer to T from other side
 
std::size_t size_type
type used to represent sizes
 
static int s_debugflag
debug flag
 
BidirMMapPipe & operator<<(const T *tptr)
write raw pointer to T to other side
 
static BidirMMapPipe & flush(BidirMMapPipe &pipe)
for usage a la "pipe << flush;"
 
int m_outpipe
pipe end to which data may be written
 
Page * m_freelist
linked list: free pages
 
static void setDebugflag(int flag)
set the debug flags
 
pid_t m_childPid
pid of the child (zero if we're child)
 
BidirMMapPipe & operator>>(BidirMMapPipe &(*manip)(BidirMMapPipe &))
I/O manipulator support.
 
Page * m_pages
pointer to first page
 
unsigned m_refcnt
reference counter
 
unsigned char m_npages
length in pages
 
PageChunk * m_parent
pointer to parent pool