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) )
close();
70 int numberUsers, openCount, closeCount;
73 template <
class Owner,
class Data>
75 if (closeCount != numberUsers || openCount != numberUsers) {
76 CkPrintf(
"OwnerBox::clientAdd() while in use\n");
78 ++numberUsers; ++closeCount; ++openCount;
81 template <
class Owner,
class Data>
87 template <
class Owner,
class Data>
89 if (closeCount != numberUsers || openCount != numberUsers) {
90 CkPrintf(
"OwnerBox::clientRemove() while in use\n");
92 if ( ! numberUsers-- ) {
93 CkPrintf(
"OwnerBox::clientRemove() - no registrants remaining\n");
96 closeCount--; openCount--;
100 template <
class Owner,
class Data>
106 template <
class Owner,
class Data>
108 if (!closeCount && !openCount) {
109 data = 0; closeCount = openCount = numberUsers;
110 (owner->*callback)();
112 CkPrintf(
"OwnerBox::close() - close called, but closeCount %d openCount %d\n", closeCount, openCount);
Data * clientOpen(int count=1)
static __global__ void(const patch_pair *patch_pairs, const atom *atoms, const atom_param *atom_params, const int *vdw_types, unsigned int *plist, float4 *tmpforces, float4 *slow_tmpforces, float4 *forces, float4 *slow_forces, float *tmpvirials, float *slow_tmpvirials, float *virials, float *slow_virials, unsigned int *global_counters, int *force_ready_queue, const unsigned int *overflow_exclusions, const int npatches, const int block_begin, const int total_block_count, int *block_order, exclmask *exclmasks, const int lj_table_size, const float3 lata, const float3 latb, const float3 latc, const float cutoff2, const float plcutoff2, const int doSlow)
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)