Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMapFile Class Reference

This class implements a shared memory region mapped to a file.

Objects can be placed into this shared memory area using the Add() member function. To actually place a copy of the object is shared memory call Update() also whenever the mapped object(s) change(s) call Update() to put a fresh copy in the shared memory. This extra step is necessary since it is not possible to share objects with virtual pointers between processes (the vtbl ptr points to the originators unique address space and can not be used by the consumer process(es)). Consumer processes can map the memory region from this file and access the objects stored in it via the Get() method (which returns a copy of the object stored in the shared memory with correct vtbl ptr set). Only objects of classes with a Streamer() member function defined can be shared.

I know the current implementation is not ideal (you need to copy to and from the shared memory file) but the main problem is with the class' virtual_table pointer. This pointer points to a table unique for every process. Therefore, different options are:

  1. One could allocate an object directly in shared memory in the producer, but the consumer still has to copy the object from shared memory into a local object which has the correct vtbl pointer for that process (copy ctor's can be used for creating the local copy).
  2. Another possibility is to only allow objects without virtual functions in shared memory (like simple C structs), or to forbid (how?) the consumer from calling any virtual functions of the objects in shared memory.
  3. A last option is to copy the object internals to shared memory and copy them again from there. This is what is done in the TMapFile (using the object Streamer() to make a deep copy).

Option 1) saves one copy, but requires solid copy ctor's (along the full inheritance chain) to rebuild the object in the consumer. Most classes don't provide these copy ctor's, especially not when objects contain collections, etc. 2) is too limiting or dangerous (calling accidentally a virtual function will segv). So since we have a robust Streamer mechanism I opted for 3).

Definition at line 25 of file TMapFile.h.

Public Types

enum  { kDefaultMapSize = 0x80000 }
 
- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) }
 
enum  EStatusBits {
  kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) ,
  kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 ))
}
 

Public Member Functions

virtual ~TMapFile ()
 TMapFiles may not be deleted, since we want to keep the complete TMapFile object in the mapped file for later re-use.
 
void Add (const TObject *obj, const char *name="")
 Add an object to the list of objects to be stored in shared memory.
 
void Browse (TBrowser *b) override
 Browse contents of TMapFile.
 
Bool_t cd (const char *path=nullptr)
 Cd to associated directory.
 
void Close (Option_t *option="")
 Close a mapped file.
 
TObjectGet (const char *name, TObject *retObj=nullptr)
 Return pointer to object retrieved from shared memory.
 
void * GetBaseAddr () const
 
void * GetBreakval () const
 Return the current location in the memory region for this malloc heap which represents the end of memory in use.
 
TDirectoryGetDirectory () const
 
Int_t GetFd () const
 
TMapRecGetFirst () const
 
TMapRecGetLast () const
 
void * GetMmallocDesc () const
 
const char * GetName () const override
 Returns name of object.
 
const char * GetOption () const override
 
Int_t GetSize () const
 
const char * GetTitle () const override
 Returns title of object.
 
TClassIsA () const override
 
Bool_t IsFolder () const override
 Returns kTRUE in case object is a folder (i.e. contains browsable lists).
 
Bool_t IsWritable () const
 
void ls (Option_t *option="") const override
 List contents of TMapFile.
 
void operator delete (void *vp)
 Need special "operator delete" in which we close the shared memory.
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
void * OrgAddress (void *addr) const
 
void Print (Option_t *option="") const override
 Print some info about the mapped file.
 
TObjectRemove (const char *name)
 
TObjectRemove (TObject *obj)
 
void RemoveAll ()
 Remove all objects from shared memory.
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
void Update (TObject *obj=nullptr)
 Update an object (or all objects, if obj == 0) in shared memory.
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static TMapFileCreate (const char *name, Option_t *option="READ", Int_t size=kDefaultMapSize, const char *title="")
 Create a memory mapped file.
 
static const char * DeclFileName ()
 
static void SetMapAddress (Longptr_t addr)
 Set preferred map address.
 
static TMapFileWhichMapFile (void *addr)
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Protected Member Functions

 TMapFile ()
 Default ctor. Does not much except setting some basic values.
 
 TMapFile (const char *name, const char *title, Option_t *option, Int_t size, TMapFile *&newMapFile)
 Create a memory mapped file.
 
 TMapFile (const TMapFile &f, Longptr_t offset=0)
 Private copy ctor.
 
Int_t AcquireSemaphore ()
 Acquire semaphore. Returns 0 if OK, -1 on error.
 
void CreateSemaphore (Int_t pid=0)
 Create semaphore used for synchronizing access to shared memory.
 
void DeleteSemaphore ()
 Delete the semaphore.
 
TMapFileFindShadowMapFile ()
 Returns shadow map file.
 
Int_t GetBestBuffer ()
 Return the best buffer size for objects in this file.
 
void InitDirectory ()
 Create the directory associated to this mapfile.
 
TMapFileoperator= (const TMapFile &rhs)=delete
 
Int_t ReleaseSemaphore ()
 Release semaphore. Returns 0 if OK, -1 on error.
 
TObjectRemove (const char *name, Bool_t lock)
 Remove object by name from shared memory.
 
TObjectRemove (TObject *obj, Bool_t lock)
 Remove object from shared memory.
 
void SumBuffer (Int_t bufsize)
 Increment statistics for buffer sizes of objects in this file.
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

Static Protected Member Functions

static void * MapToAddress ()
 Return the base address at which we would like the next TMapFile's mapped data to start.
 

Private Attributes

ULongptr_t fBaseAddr
 Base address of mapped memory region.
 
TListfBrowseList
 List of KeyMapFile objects.
 
TDirectoryfDirectory
 Pointer to directory associated to this mapfile.
 
Longptr_t fFd
 Descriptor of mapped file.
 
TMapRecfFirst
 List of streamed objects is shared memory.
 
TObjectfGetting
 Don't deadlock in update mode, when from Get() Add() is called.
 
ULongptr_t fhSemaphore
 HANDLE of WIN32 Mutex object to implement semaphore.
 
TMapRecfLast
 Last object in list of shared objects.
 
void * fMmallocDesc
 Pointer to mmalloc descriptor.
 
char * fName
 Name of mapped file.
 
Longptr_t fOffset
 Offset in bytes for region mapped by reader.
 
char * fOption
 Directory creation options.
 
Longptr_t fSemaphore
 Modification semaphore (or getpid() for WIN32)
 
Int_t fSize
 Original start size of memory mapped region.
 
Double_t fSum2Buffer
 Sum of squares of buffer sizes of objects written so far.
 
Double_t fSumBuffer
 Sum of buffer sizes of objects written so far.
 
char * fTitle
 Title of mapped file.
 
Int_t fVersion
 ROOT version (or -1 for shadow map file)
 
Bool_t fWritable
 TRUE if mapped file opened in RDWR mode.
 
Int_t fWritten
 Number of objects written so far.
 

Static Private Attributes

static Longptr_t fgMapAddress = 0
 Map to this address, set address via SetMapAddress()
 
static void * fgMmallocDesc = 0
 Used in Close() and operator delete()
 

Friends

class TMapRec
 

Additional Inherited Members

- Protected Types inherited from TObject
enum  { kOnlyPrepStep = (1ULL << ( 3 )) }
 

#include <TMapFile.h>

Inheritance diagram for TMapFile:
[legend]

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kDefaultMapSize 

Definition at line 76 of file TMapFile.h.

Constructor & Destructor Documentation

◆ TMapFile() [1/3]

TMapFile::TMapFile ( )
protected

Default ctor. Does not much except setting some basic values.

Definition at line 198 of file TMapFile.cxx.

◆ TMapFile() [2/3]

TMapFile::TMapFile ( const char *  name,
const char *  title,
Option_t option,
Int_t  size,
TMapFile *&  newMapFile 
)
protected

Create a memory mapped file.

This opens a file (to which the memory will be mapped) and attaches a memory region to it. Option can be either: "NEW", "CREATE", "RECREATE", "UPDATE" or "READ" (see TFile). The default open mode is "READ". The size argument specifies the maximum size of shared memory file in bytes. This protected ctor is called via the static Create() method.

Definition at line 232 of file TMapFile.cxx.

◆ TMapFile() [3/3]

TMapFile::TMapFile ( const TMapFile f,
Longptr_t  offset = 0 
)
protected

Private copy ctor.

Used by the ctor to create a new version of TMapFile in the memory mapped heap. It's main purpose is to correctly create the string data members.

Definition at line 513 of file TMapFile.cxx.

◆ ~TMapFile()

TMapFile::~TMapFile ( )
virtual

TMapFiles may not be deleted, since we want to keep the complete TMapFile object in the mapped file for later re-use.

To enforce this the delete operator has been made private. Use Close() to properly terminate a TMapFile (also done via the TROOT dtor).

Definition at line 547 of file TMapFile.cxx.

Member Function Documentation

◆ AcquireSemaphore()

Int_t TMapFile::AcquireSemaphore ( )
protected

Acquire semaphore. Returns 0 if OK, -1 on error.

Definition at line 877 of file TMapFile.cxx.

◆ Add()

void TMapFile::Add ( const TObject obj,
const char *  name = "" 
)

Add an object to the list of objects to be stored in shared memory.

To place the object actually into shared memory call Update().

Definition at line 595 of file TMapFile.cxx.

◆ Browse()

void TMapFile::Browse ( TBrowser b)
overridevirtual

Browse contents of TMapFile.

Reimplemented from TObject.

Definition at line 1041 of file TMapFile.cxx.

◆ cd()

Bool_t TMapFile::cd ( const char *  path = nullptr)

Cd to associated directory.

Definition at line 1068 of file TMapFile.cxx.

◆ Class()

static TClass * TMapFile::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TMapFile::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TMapFile::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 117 of file TMapFile.h.

◆ Close()

void TMapFile::Close ( Option_t option = "")

Close a mapped file.

First detach mapped memory then close file. No member functions of a TMapFile that was opened in write mode may be called after Close() (this includes, of course, "delete" which would call the dtors). The option="dtor" is only used when called via the ~TMapFile.

Definition at line 954 of file TMapFile.cxx.

◆ Create()

TMapFile * TMapFile::Create ( const char *  name,
Option_t option = "READ",
Int_t  size = kDefaultMapSize,
const char *  title = "" 
)
static

Create a memory mapped file.

This opens a file (to which the memory will be mapped) and attaches a memory region to it. Option can be either: "NEW", "CREATE", "RECREATE", "UPDATE" or "READ" (see TFile). The default open mode is "READ". The size argument specifies the maximum size of shared memory file in bytes. TMapFile's can only be created via this method. Create() enforces that a TMapFile is always on the memory mapped heap (when "NEW", "CREATE" or "RECREATE" are used).

Definition at line 1147 of file TMapFile.cxx.

◆ CreateSemaphore()

void TMapFile::CreateSemaphore ( Int_t  pid = 0)
protected

Create semaphore used for synchronizing access to shared memory.

Definition at line 822 of file TMapFile.cxx.

◆ DeclFileName()

static const char * TMapFile::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 117 of file TMapFile.h.

◆ DeleteSemaphore()

void TMapFile::DeleteSemaphore ( )
protected

Delete the semaphore.

Definition at line 852 of file TMapFile.cxx.

◆ FindShadowMapFile()

TMapFile * TMapFile::FindShadowMapFile ( )
protected

Returns shadow map file.

Definition at line 999 of file TMapFile.cxx.

◆ Get()

TObject * TMapFile::Get ( const char *  name,
TObject delObj = nullptr 
)

Return pointer to object retrieved from shared memory.

The object must be deleted after use. If delObj is a pointer to a previously allocated object it will be deleted. Returns 0 in case object with the given name does not exist.

Definition at line 775 of file TMapFile.cxx.

◆ GetBaseAddr()

void * TMapFile::GetBaseAddr ( ) const
inline

Definition at line 88 of file TMapFile.h.

◆ GetBestBuffer()

Int_t TMapFile::GetBestBuffer ( )
protected

Return the best buffer size for objects in this file.

The best buffer size is estimated based on the current mean value and standard deviation of all objects written so far to this file. Returns mean value + one standard deviation.

Definition at line 1117 of file TMapFile.cxx.

◆ GetBreakval()

void * TMapFile::GetBreakval ( ) const

Return the current location in the memory region for this malloc heap which represents the end of memory in use.

Returns 0 if map file was closed.

Definition at line 1129 of file TMapFile.cxx.

◆ GetDirectory()

TDirectory * TMapFile::GetDirectory ( ) const
inline

Definition at line 90 of file TMapFile.h.

◆ GetFd()

Int_t TMapFile::GetFd ( ) const
inline

Definition at line 91 of file TMapFile.h.

◆ GetFirst()

TMapRec * TMapFile::GetFirst ( ) const
inline

Definition at line 97 of file TMapFile.h.

◆ GetLast()

TMapRec * TMapFile::GetLast ( ) const
inline

Definition at line 98 of file TMapFile.h.

◆ GetMmallocDesc()

void * TMapFile::GetMmallocDesc ( ) const
inline

Definition at line 92 of file TMapFile.h.

◆ GetName()

const char * TMapFile::GetName ( ) const
inlineoverridevirtual

Returns name of object.

This default method returns the class name. Classes that give objects a name should override this method.

Reimplemented from TObject.

Definition at line 93 of file TMapFile.h.

◆ GetOption()

const char * TMapFile::GetOption ( ) const
inlineoverridevirtual

Reimplemented from TObject.

Definition at line 95 of file TMapFile.h.

◆ GetSize()

Int_t TMapFile::GetSize ( ) const
inline

Definition at line 94 of file TMapFile.h.

◆ GetTitle()

const char * TMapFile::GetTitle ( ) const
inlineoverridevirtual

Returns title of object.

This default method returns the class title (i.e. description). Classes that give objects a title should override this method.

Reimplemented from TObject.

Definition at line 96 of file TMapFile.h.

◆ InitDirectory()

void TMapFile::InitDirectory ( )
protected

Create the directory associated to this mapfile.

Definition at line 580 of file TMapFile.cxx.

◆ IsA()

TClass * TMapFile::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TObject.

Definition at line 117 of file TMapFile.h.

◆ IsFolder()

Bool_t TMapFile::IsFolder ( ) const
overridevirtual

Returns kTRUE in case object is a folder (i.e. contains browsable lists).

Reimplemented from TObject.

Definition at line 1032 of file TMapFile.cxx.

◆ IsWritable()

Bool_t TMapFile::IsWritable ( ) const
inline

Definition at line 100 of file TMapFile.h.

◆ ls()

void TMapFile::ls ( Option_t option = "") const
overridevirtual

List contents of TMapFile.

Reimplemented from TObject.

Definition at line 1078 of file TMapFile.cxx.

◆ MapToAddress()

void * TMapFile::MapToAddress ( )
staticprotected

Return the base address at which we would like the next TMapFile's mapped data to start.

For now, we let the system decide (start address 0). There are a lot of issues to deal with here to make this work reasonably, including:

  • Avoid memory collisions with existing mapped address spaces
  • Reclaim address spaces when their mmalloc heaps are unmapped
  • When mmalloc heaps are shared between processes they have to be mapped at the same addresses in each

Once created, a mmalloc heap that is to be mapped back in must be mapped at the original address. I.e. each TMapFile will expect to be remapped at it's original address. This becomes a problem if the desired address is already in use.

Definition at line 1206 of file TMapFile.cxx.

◆ operator delete()

void TMapFile::operator delete ( void *  ptr)

Need special "operator delete" in which we close the shared memory.

This has to be done after the dtor chain has been finished.

Definition at line 1222 of file TMapFile.cxx.

◆ operator new() [1/2]

void * TMapFile::operator new ( size_t  sz)
inline

Definition at line 80 of file TMapFile.h.

◆ operator new() [2/2]

void * TMapFile::operator new ( size_t  sz,
void *  vp 
)
inline

Definition at line 82 of file TMapFile.h.

◆ operator new[]() [1/2]

void * TMapFile::operator new[] ( size_t  sz)
inline

Definition at line 81 of file TMapFile.h.

◆ operator new[]() [2/2]

void * TMapFile::operator new[] ( size_t  sz,
void *  vp 
)
inline

Definition at line 83 of file TMapFile.h.

◆ operator=()

TMapFile & TMapFile::operator= ( const TMapFile rhs)
protecteddelete

◆ OrgAddress()

void * TMapFile::OrgAddress ( void *  addr) const
inline

Definition at line 101 of file TMapFile.h.

◆ Print()

void TMapFile::Print ( Option_t option = "") const
overridevirtual

Print some info about the mapped file.

Reimplemented from TObject.

Definition at line 1015 of file TMapFile.cxx.

◆ ReleaseSemaphore()

Int_t TMapFile::ReleaseSemaphore ( )
protected

Release semaphore. Returns 0 if OK, -1 on error.

Definition at line 922 of file TMapFile.cxx.

◆ Remove() [1/4]

TObject * TMapFile::Remove ( const char *  name)
inline

Definition at line 109 of file TMapFile.h.

◆ Remove() [2/4]

TObject * TMapFile::Remove ( const char *  name,
Bool_t  lock 
)
protected

Remove object by name from shared memory.

Returns pointer to removed object if successful, 0 otherwise.

Definition at line 713 of file TMapFile.cxx.

◆ Remove() [3/4]

TObject * TMapFile::Remove ( TObject obj)
inline

Definition at line 108 of file TMapFile.h.

◆ Remove() [4/4]

TObject * TMapFile::Remove ( TObject obj,
Bool_t  lock 
)
protected

Remove object from shared memory.

Returns pointer to removed object if successful, 0 otherwise.

Definition at line 674 of file TMapFile.cxx.

◆ RemoveAll()

void TMapFile::RemoveAll ( )

Remove all objects from shared memory.

Definition at line 750 of file TMapFile.cxx.

◆ SetMapAddress()

void TMapFile::SetMapAddress ( Longptr_t  addr)
static

Set preferred map address.

Find out preferred map address as follows:

  1. Run consumer program to find the preferred map address. Remember begin of mapped region, i.e. 0x40b4c000
    $ root
    root [0] m = TMapFile::Create("dummy.map", "recreate", 10000000);
    root [1] m.Print()
    Memory mapped file: dummy.map
    Title:
    Option: CREATE
    Mapped Memory region: 0x40b4c000 - 0x40d95f00 (2.29 MB)
    Current breakval: 0x40b53000
    root [2] .q
    $ rm dummy.map
    float * q
    static TMapFile * Create(const char *name, Option_t *option="READ", Int_t size=kDefaultMapSize, const char *title="")
    Create a memory mapped file.
    void Print(Option_t *option="") const override
    Dump this marker with its attributes.
    Definition TMarker.cxx:334
    Definition file.py:1
    TMarker m
    Definition textangle.C:8
  2. Add to producer program, just before creating the TMapFile: TMapFile::SetMapAddress(0x40b4c000);

Repeat this if more than one map file is being used. The above procedure allow programs using, e.g., different number of shared libraries (that cause the default mapping address to be different) to create shared memory regions in the same location without overwriting a shared library. The above assumes the consumer program is larger (i.e. has more shared memory occupied) than the producer. If this is not true inverse the procedure.

Definition at line 1184 of file TMapFile.cxx.

◆ Streamer()

void TMapFile::Streamer ( TBuffer R__b)
overridevirtual

Stream an object of class TObject.

Reimplemented from TObject.

◆ StreamerNVirtual()

void TMapFile::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 117 of file TMapFile.h.

◆ SumBuffer()

void TMapFile::SumBuffer ( Int_t  bufsize)
protected

Increment statistics for buffer sizes of objects in this file.

Definition at line 1103 of file TMapFile.cxx.

◆ Update()

void TMapFile::Update ( TObject obj = nullptr)

Update an object (or all objects, if obj == 0) in shared memory.

Definition at line 634 of file TMapFile.cxx.

◆ WhichMapFile()

TMapFile * TMapFile::WhichMapFile ( void *  addr)
static

Definition at line 1232 of file TMapFile.cxx.

Friends And Related Symbol Documentation

◆ TMapRec

friend class TMapRec
friend

Definition at line 27 of file TMapFile.h.

Member Data Documentation

◆ fBaseAddr

ULongptr_t TMapFile::fBaseAddr
private

Base address of mapped memory region.

Definition at line 36 of file TMapFile.h.

◆ fBrowseList

TList* TMapFile::fBrowseList
private

List of KeyMapFile objects.

Definition at line 42 of file TMapFile.h.

◆ fDirectory

TDirectory* TMapFile::fDirectory
private

Pointer to directory associated to this mapfile.

Definition at line 41 of file TMapFile.h.

◆ fFd

Longptr_t TMapFile::fFd
private

Descriptor of mapped file.

Definition at line 30 of file TMapFile.h.

◆ fFirst

TMapRec* TMapFile::fFirst
private

List of streamed objects is shared memory.

Definition at line 38 of file TMapFile.h.

◆ fGetting

TObject* TMapFile::fGetting
private

Don't deadlock in update mode, when from Get() Add() is called.

Definition at line 46 of file TMapFile.h.

◆ fgMapAddress

Longptr_t TMapFile::fgMapAddress = 0
staticprivate

Map to this address, set address via SetMapAddress()

Definition at line 51 of file TMapFile.h.

◆ fgMmallocDesc

void * TMapFile::fgMmallocDesc = 0
staticprivate

Used in Close() and operator delete()

Definition at line 52 of file TMapFile.h.

◆ fhSemaphore

ULongptr_t TMapFile::fhSemaphore
private

HANDLE of WIN32 Mutex object to implement semaphore.

Definition at line 45 of file TMapFile.h.

◆ fLast

TMapRec* TMapFile::fLast
private

Last object in list of shared objects.

Definition at line 39 of file TMapFile.h.

◆ fMmallocDesc

void* TMapFile::fMmallocDesc
private

Pointer to mmalloc descriptor.

Definition at line 35 of file TMapFile.h.

◆ fName

char* TMapFile::fName
private

Name of mapped file.

Definition at line 32 of file TMapFile.h.

◆ fOffset

Longptr_t TMapFile::fOffset
private

Offset in bytes for region mapped by reader.

Definition at line 40 of file TMapFile.h.

◆ fOption

char* TMapFile::fOption
private

Directory creation options.

Definition at line 34 of file TMapFile.h.

◆ fSemaphore

Longptr_t TMapFile::fSemaphore
private

Modification semaphore (or getpid() for WIN32)

Definition at line 44 of file TMapFile.h.

◆ fSize

Int_t TMapFile::fSize
private

Original start size of memory mapped region.

Definition at line 37 of file TMapFile.h.

◆ fSum2Buffer

Double_t TMapFile::fSum2Buffer
private

Sum of squares of buffer sizes of objects written so far.

Definition at line 49 of file TMapFile.h.

◆ fSumBuffer

Double_t TMapFile::fSumBuffer
private

Sum of buffer sizes of objects written so far.

Definition at line 48 of file TMapFile.h.

◆ fTitle

char* TMapFile::fTitle
private

Title of mapped file.

Definition at line 33 of file TMapFile.h.

◆ fVersion

Int_t TMapFile::fVersion
private

ROOT version (or -1 for shadow map file)

Definition at line 31 of file TMapFile.h.

◆ fWritable

Bool_t TMapFile::fWritable
private

TRUE if mapped file opened in RDWR mode.

Definition at line 43 of file TMapFile.h.

◆ fWritten

Int_t TMapFile::fWritten
private

Number of objects written so far.

Definition at line 47 of file TMapFile.h.

Libraries for TMapFile:

The documentation for this class was generated from the following files: