NAMD
Public Member Functions | Friends | List of all members
OwnerBox< Owner, Data > Class Template Reference

#include <OwnerBox.h>

Public Member Functions

 OwnerBox (Owner *o, void(Owner::*fn)())
 
 OwnerBox (Owner *o, void(Owner::*fn)(), int id, int tp)
 
 ~OwnerBox (void)
 
void open (Data *d)
 
void close (void)
 
Box< Owner, Data > * checkOut (int id)
 
void checkIn (Box< Owner, Data > *box)
 
int isOpen ()
 
void clientAdd ()
 
void clientRemove ()
 
Data * clientOpen (int count=1)
 
void clientClose (int count=1)
 

Friends

class Box< Owner, Data >
 

Detailed Description

template<class Owner, class Data>
class OwnerBox< Owner, Data >

Definition at line 14 of file OwnerBox.h.

Constructor & Destructor Documentation

◆ OwnerBox() [1/2]

template<class Owner, class Data>
OwnerBox< Owner, Data >::OwnerBox ( Owner *  o,
void(Owner::*)()  fn 
)
inline

Definition at line 22 of file OwnerBox.h.

22  :
23  bid(-1), type(-1),
24  owner(o), callback(fn), data(0),
25  numberUsers(0), openCount(0), closeCount(0) {};

◆ OwnerBox() [2/2]

template<class Owner, class Data>
OwnerBox< Owner, Data >::OwnerBox ( Owner *  o,
void(Owner::*)()  fn,
int  id,
int  tp 
)
inline

Definition at line 27 of file OwnerBox.h.

27  :
28  bid(id), type(tp),
29  owner(o), callback(fn), data(0),
30  numberUsers(0), openCount(0), closeCount(0) {};

◆ ~OwnerBox()

template<class Owner, class Data>
OwnerBox< Owner, Data >::~OwnerBox ( void  )
inline

Definition at line 33 of file OwnerBox.h.

33  {
34  if (numberUsers) {
35  CkPrintf("OwnerBox::~OwnerBox() - still have boxes out there!\n");
36  }
37  }

Member Function Documentation

◆ checkIn()

template<class Owner, class Data>
void OwnerBox< Owner, Data >::checkIn ( Box< Owner, Data > *  box)
inline

◆ checkOut()

template<class Owner , class Data >
Box< Owner, Data > * OwnerBox< Owner, Data >::checkOut ( int  id)
inline

◆ clientAdd()

template<class Owner , class Data >
void OwnerBox< Owner, Data >::clientAdd ( void  )
inline

Definition at line 77 of file OwnerBox.h.

Referenced by HomePatch::registerProxy().

77  {
78  if (closeCount != numberUsers || openCount != numberUsers) {
79  CkPrintf("OwnerBox::clientAdd() while in use\n");
80  }
81  ++numberUsers; ++closeCount; ++openCount;
82 }

◆ clientClose()

template<class Owner, class Data>
void OwnerBox< Owner, Data >::clientClose ( int  count = 1)
inline

Definition at line 62 of file OwnerBox.h.

Referenced by HomePatch::receiveResults().

62  {
63  if ( ! (closeCount -= count) ){
64  //fprintf(stderr, "Calling clientClose()!\n");
65  close();
66  }
67  }
void close(void)
Definition: OwnerBox.h:110

◆ clientOpen()

template<class Owner, class Data>
Data* OwnerBox< Owner, Data >::clientOpen ( int  count = 1)
inline

Definition at line 58 of file OwnerBox.h.

Referenced by HomePatch::receiveResults().

58  {
59  openCount -= count;
60  return data;
61  }

◆ clientRemove()

template<class Owner , class Data >
void OwnerBox< Owner, Data >::clientRemove ( )
inline

Definition at line 91 of file OwnerBox.h.

Referenced by HomePatch::unregisterProxy().

91  {
92  if (closeCount != numberUsers || openCount != numberUsers) {
93  CkPrintf("OwnerBox::clientRemove() while in use\n");
94  }
95  if ( ! numberUsers-- ) {
96  CkPrintf("OwnerBox::clientRemove() - no registrants remaining\n");
97  numberUsers = 0;
98  } else {
99  closeCount--; openCount--;
100  }
101 }

◆ close()

template<class Owner , class Data >
void OwnerBox< Owner, Data >::close ( void  )
inline

Definition at line 110 of file OwnerBox.h.

Referenced by OwnerBox< Patch, CompAtom >::clientClose(), Box< Patch, CompAtom >::close(), OwnerBox< Patch, CompAtom >::open(), and Box< Patch, CompAtom >::skip().

110  {
111  if (!closeCount && !openCount) {
112  data = 0; closeCount = openCount = numberUsers;
113  (owner->*callback)();
114  } else {
115  CkPrintf("OwnerBox::close() - close called, but closeCount %d openCount %d\n", closeCount, openCount);
116  }
117 }

◆ isOpen()

template<class Owner, class Data>
int OwnerBox< Owner, Data >::isOpen ( )
inline

Definition at line 51 of file OwnerBox.h.

Referenced by HomePatch::boxClosed().

51  {
52  return (closeCount != numberUsers || openCount != numberUsers);
53  }

◆ open()

template<class Owner, class Data>
void OwnerBox< Owner, Data >::open ( Data *  d)
inline

Definition at line 39 of file OwnerBox.h.

Referenced by Patch::positionsReady().

39  {
40  closeCount = openCount = numberUsers;
41  data = d;
42  if ( ! closeCount ) close();
43  }
void close(void)
Definition: OwnerBox.h:110

Friends And Related Function Documentation

◆ Box< Owner, Data >

template<class Owner, class Data>
friend class Box< Owner, Data >
friend

Definition at line 16 of file OwnerBox.h.


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