12 template <
class Owner,
class Data>
class Box;
14 template <
class Owner,
class Data>
class OwnerBox {
16 friend class Box<Owner,Data>;
24 owner(o), callback(fn), data(0),
25 numberUsers(0), openCount(0), closeCount(0) {};
27 OwnerBox(Owner *o,
void (Owner::*fn)(),
int id ,
int tp) :
29 owner(o), callback(fn), data(0),
30 numberUsers(0), openCount(0), closeCount(0) {};
35 CkPrintf(
"OwnerBox::~OwnerBox() - still have boxes out there!\n");
40 closeCount = openCount = numberUsers;
42 if ( ! closeCount )
close();
45 inline void close(
void);
52 return (closeCount != numberUsers || openCount != numberUsers);
63 if ( ! (closeCount -= count) ){
71 void (Owner::*callback)(void);
73 int numberUsers, openCount, closeCount;
76 template <
class Owner,
class Data>
78 if (closeCount != numberUsers || openCount != numberUsers) {
79 CkPrintf(
"OwnerBox::clientAdd() while in use\n");
81 ++numberUsers; ++closeCount; ++openCount;
84 template <
class Owner,
class Data>
90 template <
class Owner,
class Data>
92 if (closeCount != numberUsers || openCount != numberUsers) {
93 CkPrintf(
"OwnerBox::clientRemove() while in use\n");
95 if ( ! numberUsers-- ) {
96 CkPrintf(
"OwnerBox::clientRemove() - no registrants remaining\n");
99 closeCount--; openCount--;
103 template <
class Owner,
class Data>
109 template <
class Owner,
class Data>
111 if (!closeCount && !openCount) {
112 data = 0; closeCount = openCount = numberUsers;
113 (owner->*callback)();
115 CkPrintf(
"OwnerBox::close() - close called, but closeCount %d openCount %d\n", closeCount, openCount);
Data * clientOpen(int count=1)
void checkIn(Box< Owner, Data > *box)
OwnerBox(Owner *o, void(Owner::*fn)())
OwnerBox(Owner *o, void(Owner::*fn)(), int id, int tp)
void clientClose(int count=1)
Box< Owner, Data > * checkOut(int id)