|
ROOT
Reference Guide |
|
Go to the documentation of this file.
10 #ifndef BIDIRMMAPPIPE_H
11 #define BIDIRMMAPPIPE_H
18 #define BEGIN_NAMESPACE_ROOFIT namespace RooFit {
19 #define END_NAMESPACE_ROOFIT }
26 class BidirMMapPipeException;
92 PageChunk(PagePool* parent,
unsigned length,
unsigned nPgPerGroup);
109 return reinterpret_cast<unsigned char*
>(
m_end) -
110 reinterpret_cast<unsigned char*
>(
m_begin);
169 Page*
page(
unsigned pgno)
const;
175 unsigned pageno(Page* p)
const;
384 typedef BidirMMapPipe_impl::BidirMMapPipeException
Exception;
419 BidirMMapPipe(
bool useExceptions =
true,
bool useSocketpair =
false);
754 #define STREAMOP(TYPE) \
755 BidirMMapPipe& operator<<(const TYPE& val) \
756 { write(&val, sizeof(TYPE)); return *this; } \
757 BidirMMapPipe& operator>>(TYPE& val) \
758 { read(&val, sizeof(TYPE)); return *this; }
815 {
write(&tptr,
sizeof(tptr));
return *
this; }
826 {
read(&tptr,
sizeof(tptr));
return *
this; }
839 {
return manip(*
this); }
852 {
return manip(*
this); }
896 static BidirMMapPipe_impl::PagePool&
pagepool();
930 ssize_t (*xferfn)(
int,
void*, std::size_t));
933 ssize_t (*xferfn)(
int,
const void*, std::size_t))
936 reinterpret_cast<ssize_t (*)(
937 int,
void*, std::size_t)
>(xferfn));
979 int doClose(
bool force,
bool holdlock =
false);
981 void doFlush(
bool forcePartialPages =
true);
987 #undef BEGIN_NAMESPACE_ROOFIT
988 #undef END_NAMESPACE_ROOFIT
PageChunk & operator=(const PageChunk &)
forbid assignment
unsigned m_nPgPerGrp
number of pages per group
@ ReadError
pipe error read end
BidirMMapPipe * pipe
pipe of interest
size_type write(const void *addr, size_type sz)
wirte to pipe
bool empty() const
return true if no used page groups in this chunk
PollEntry(BidirMMapPipe *_pipe)
poll a pipe for all events
unsigned pageno(Page *p) const
perform page to page number mapping
pid_t m_parentPid
pid of the parent
@ WriteError
pipe error Write end
static int s_debugflag
debug flag
@ ReadInvalid
read end of pipe invalid
unsigned m_refcnt
reference counter
static BidirMMapPipe_impl::PagePool * s_pagepool
pool of mmapped pages
@ Unknown
don't know yet what'll work
static std::list< BidirMMapPipe * > s_openpipes
list of open BidirMMapPipes
STREAMOP(unsigned short)
C++ style stream operators for unsigned short.
int m_flags
flags (e.g. end of file)
static pthread_mutex_t s_openpipesmutex
protects s_openpipes
BidirMMapPipe creates a bidirectional channel between the current process and a child it forks.
BidirMMapPipe & operator<<(const char *str)
write a C-style string
@ Writable
pipe can be written to
static unsigned pagesize()
return the logical page size
~BidirMMapPipe()
destructor
unsigned events
events of interest (or'ed bitmask)
Page * m_pages
pointer to first page
pid_t pidOtherEnd() const
return PID of the process on the other end of the pipe
BidirMMapPipeException Exception
convenience typedef
static void domunmap(void *p, unsigned len)
munmap pages p, len is length of mmapped area in bytes
STREAMOP(int)
C++ style stream operators for int.
static unsigned getPageSize()
determine page size at run time
#define BEGIN_NAMESPACE_ROOFIT
STREAMOP(float)
C++ style stream operators for float.
STREAMOP(unsigned long)
C++ style stream operators for unsigned long.
PageChunk * m_parent
pointer to parent pool
Page * operator[](unsigned pgno) const
return page number pageno
@ FlushThresh
flush threshold
void push(const Pages &p)
push a group of pages onto the free list
#define END_NAMESPACE_ROOFIT
BidirMMapPipe_impl::BidirMMapPipeException Exception
convenience typedef for BidirMMapPipeException
unsigned char m_npages
length in pages
bool eof() const
true if end-of-file
void markPageDirty(Page *p)
put on dirty pages list
STREAMOP(long long)
C++ style stream operators for long long.
STREAMOP(unsigned int)
C++ style stream operators for unsigned int.
handle class for a number of Pages
static void setDebugflag(int flag)
set the debug flags
unsigned npages() const
return number of pages accessible
PagePool * m_parent
parent page pool
BidirMMapPipe_impl::Page Page
convenience typedef for Page
pid_t m_childPid
pid of the child (zero if we're child)
STREAMOP(double)
C++ style stream operators for double.
MMapVariety
type of mmap support found
void * m_begin
pointer to start of mmapped area
bool isChild() const
return if this end of the pipe is the child end
static MMapVariety s_mmapworks
mmap variety that works on this system
PageChunk(const PageChunk &)
forbid copying
size_type bytesWritableNonBlocking()
number of bytes that can be written without blocking
@ None
nothing special on this pipe
std::vector< PollEntry > PollVector
convenience typedef for poll() interface
@ Anonymous
anonymous mmap works
PollFlags
condition flags for poll
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)
Page * busypage()
get a busy page to read data from (may block)
static int poll(PollVector &pipes, int timeout)
poll a set of pipes for events (ready to read from, ready to write to, error)
@ WriteEndOfFile
write pipe in end-of-file state
std::list< void * > m_freelist
free pages list
static unsigned lenPageList(const Page *list)
return length of a page list
int m_inpipe
pipe end from which data may be read
impl * m_pimpl
pointer to implementation
@ badbit
general I/O error
@ exceptionsbit
error reporting with exceptions
STREAMOP(unsigned long long)
C++ style stream operators for unsigned long long.
unsigned m_nUsedGrp
number of used page groups
void purge()
purge buffered data waiting to be read and/or written
int rdstate() const
return flags (end of file, BidirMMapPipe closed, ...)
@ Readable
pipe has data for reading
unsigned operator[](Page *p) const
perform page to page number mapping
size_type read(void *addr, size_type sz)
read from pipe
Page * m_freelist
linked list: free pages
int m_outpipe
pipe end to which data may be written
static BidirMMapPipe_impl::PagePool & pagepool()
return page pool
bool fail() const
logical failure (e.g.
@ WriteInvalid
write end of pipe invalid
bool good() const
status of stream is good
unsigned nPagesPerGroup() const
return number of pages per page group
size_type bytesReadableNonBlocking()
number of bytes that can be read without blocking
std::size_t size_type
type used to represent sizes
BidirMMapPipe(bool useExceptions=true, bool useSocketpair=false)
constructor (forks!)
@ Copy
mmap doesn't work, have to copy back and forth
void flush()
flush buffers with unwritten data
void sendpages(Page *plist)
send page(s) to the other end (may block)
@ TotPages
pages shared (child + parent)
static unsigned s_physpgsz
system physical page size
class representing a chunk of pages
bool operator!() const
return true if serious error (fail/bad)
STREAMOP(unsigned char)
C++ style stream operators for unsigned char.
unsigned recvpages_nonblock()
receive pages from other end (non-blocking)
@ eofbit
end of file reached
BidirMMapPipe & operator>>(char *(&str))
read a C-style string
void doFlush(bool forcePartialPages=true)
perform the flush
@ FileBacked
mmapping a temp file works
Page * page(unsigned pgno) const
return page number pageno
static void * dommap(unsigned len)
mmap pages, len is length of mmapped area in bytes
static unsigned pagesize()
return page size
bool closed() const
true if closed
@ DevZero
mmapping /dev/zero works
@ ReadEndOfFile
read pipe in end-of-file state
STREAMOP(long)
C++ style stream operators for long.
BidirMMapPipe & operator<<(BidirMMapPipe &(*manip)(BidirMMapPipe &))
I/O manipulator support.
bool usesSocketpair() const
if BidirMMapPipe uses a socketpair for communications
namespace for implementation details of BidirMMapPipe
Pages & operator=(const Pages &other)
assignment operator
void swap(Pages &other)
swap with other's contents
STREAMOP(short)
C++ style stream operators for short.
static size_type xferraw(int fd, void *addr, size_type len, ssize_t(*xferfn)(int, void *, std::size_t))
transfer bytes through the pipe (reading, writing, may block)
BidirMMapPipe & operator>>(BidirMMapPipe &(*manip)(BidirMMapPipe &))
I/O manipulator support.
BidirMMapPipe & operator<<(const T *tptr)
write raw pointer to T to other side
int doClose(bool force, bool holdlock=false)
close the pipe (no flush if forced)
@ PagesPerEnd
pages per pipe end
int close()
flush buffers, close pipe
Page * dirtypage()
get a dirty page to write data to (may block)
BidirMMapPipe & operator>>(T *&tptr)
read raw pointer to T from other side
bool bad() const
true on I/O error
@ failbit
logical failure (e.g. pipe closed)
static BidirMMapPipe & purge(BidirMMapPipe &pipe)
for usage a la "pipe << purge;"
static unsigned s_pagesize
logical page size (run-time determined)
STREAMOP(char)
C++ style stream operators for char.
friend class BidirMMapPipe_impl::Page
page is our friend
static unsigned s_pagepoolrefcnt
page pool reference counter
BidirMMapPipe & operator=(const BidirMMapPipe &)
assignment forbidden
static int debugflag()
return the current setting of the debug flag
void feedPageLists(Page *plist)
"feed" the busy and free lists with a list of pages
bool isParent() const
return if this end of the pipe is the parent end
bool full() const
return true if no free page groups in this chunk
PollEntry(BidirMMapPipe *_pipe, int _events)
poll a pipe for specified events
bool contains(const Pages &p) const
return if p is contained in this PageChunk
void zap(Pages &p)
free all pages except for those pointed to by p
BidirMMapPipe_impl::Pages m_pages
mmapped pages
unsigned recvpages()
receive a pages from the other end (may block), queue them
Page * m_dirtylist
linked list: dirty pages (data to be sent)
static unsigned physPgSz()
return the physical page size of the system
STREAMOP(bool)
C++ style stream operators for bool.
Pages()
default constructor
Pages pop()
pop a group of pages off the free list
unsigned len() const
return length of chunk
void * m_end
pointer one behind end of mmapped area
unsigned revents
events that happened (or'ed bitmask)
static MMapVariety mmapVariety()
return mmap variety support found
bool usesPipepair() const
if BidirMMapPipe uses a pipe pair for communications
Page * m_busylist
linked list: busy pages (data to be read)
static BidirMMapPipe & flush(BidirMMapPipe &pipe)
for usage a la "pipe << flush;"
static void teardownall(void)
cleanup routine - at exit, we want our children to get a SIGTERM...