BroadcastMgr Class Reference

#include <BroadcastMgr.h>

List of all members.

Public Member Functions

 BroadcastMgr ()
 ~BroadcastMgr (void)
int getbuf (BroadcastClient &b, int tag, void *msg)
void send (BroadcastClient &b, int tag, void *buf, size_t)
void subscribe (BroadcastClient &bc)
void unsubscribe (BroadcastClient &bc)
void recvBroadcast (BroadcastMsg *msg)

Static Public Member Functions

static BroadcastMgrObject ()


Detailed Description

Definition at line 87 of file BroadcastMgr.h.


Constructor & Destructor Documentation

BroadcastMgr::BroadcastMgr (  )  [inline]

Definition at line 90 of file BroadcastMgr.h.

00090                  { 
00091     CkpvAccess(BroadcastMgr_instance) = this; 
00092   }

BroadcastMgr::~BroadcastMgr ( void   ) 

Definition at line 18 of file BroadcastMgr.C.

References UniqueSetIter< T >::begin(), UniqueSetIter< T >::end(), and if().

00018                                 {
00019   UniqueSetIter<BOID> boidIter(boid);
00020   for (boidIter = boidIter.begin(); boidIter != boidIter.end(); boidIter++) {
00021     delete boidIter->broadcastSet;
00022     if (boidIter->taggedMsg) {
00023       delete boidIter->taggedMsg;
00024     }
00025   }
00026 }


Member Function Documentation

int BroadcastMgr::getbuf ( BroadcastClient b,
int  tag,
void *  msg 
)

Definition at line 30 of file BroadcastMgr.C.

References TaggedMsg::counter, UniqueSet< Elem >::find(), BroadcastClient::id, TaggedMsg::msg, TaggedMsg::msgSize, and BOID::taggedMsg.

00030                                                            {
00031   int rval = -1;
00032   TaggedMsg *tm;
00033   BOID* boidTmp = boid.find(BOID(b.id));
00034   if (!boidTmp) {
00035     return(-2);
00036   }
00037   if ( (tm = (boidTmp->taggedMsg->find(TaggedMsg(tag)))) ) {
00038     rval = tm->msgSize;
00039     memcpy(msg, tm->msg, tm->msgSize);
00040     if (!--(tm->counter)) {
00041       (boid.find(BOID(b.id)))->taggedMsg->del(TaggedMsg(tag));
00042     }
00043   }
00044   return(rval);
00045 }

static BroadcastMgr* BroadcastMgr::Object (  )  [inline, static]

Definition at line 96 of file BroadcastMgr.h.

Referenced by BroadcastClient::BroadcastClient(), SimpleBroadcastObject< Tensor >::get(), SimpleBroadcastObject< Tensor >::publish(), and BroadcastClient::~BroadcastClient().

00096                                        {
00097     return CkpvAccess(BroadcastMgr_instance);
00098   }

void BroadcastMgr::recvBroadcast ( BroadcastMsg msg  ) 

Definition at line 86 of file BroadcastMgr.C.

References UniqueSet< Elem >::add(), UniqueSetIter< T >::begin(), BOID::broadcastSet, UniqueSetIter< T >::end(), UniqueSet< Elem >::find(), BroadcastMsg::id, BroadcastMsg::msg, NAMD_bug(), BroadcastMsg::node, BroadcastMsg::size, UniqueSet< Elem >::size(), BroadcastMsg::tag, and BOID::taggedMsg.

00086                                              {
00087   BOID *b;
00088   int counter;
00089   // Check if msg->id has any registrants
00090   if ( (b = boid.find(BOID(msg->id))) ) {
00091     // add message to taggedMsg container
00092     counter = b->broadcastSet->size();
00093     if (msg->node == CkMyPe()) counter--; // get rid of sender
00094     if ( counter < 0 ) NAMD_bug("BroadcastMgr::recvBroadcast counter < 0");
00095     else if ( counter > 0 ) {
00096       b->taggedMsg->add(TaggedMsg(msg->tag,msg->size,counter,msg->msg));
00097 
00098       // inform all registrants of mew message
00099       UniqueSetIter<BroadcastClientElem> bcIter(*(b->broadcastSet));
00100       for (bcIter = bcIter.begin(); bcIter != bcIter.end(); bcIter++) {
00101         bcIter->broadcastClient->awaken(msg->id, msg->tag);
00102       }
00103     }
00104   }
00105   delete msg;
00106 }

void BroadcastMgr::send ( BroadcastClient b,
int  tag,
void *  buf,
size_t   
)

Definition at line 49 of file BroadcastMgr.C.

References BroadcastClient::id, BroadcastMsg::id, BroadcastMsg::msg, BroadcastMsg::node, BroadcastMsg::size, and BroadcastMsg::tag.

Referenced by SimpleBroadcastObject< Tensor >::publish().

00049                                                                       {
00050   BroadcastMsg* msg = new BroadcastMsg;
00051   memcpy((void*)(msg->msg),buf,size);
00052   msg->size = (int)size;
00053   msg->tag = tag;
00054   msg->id = b.id;
00055   msg->node = CkMyPe();
00056   CProxy_BroadcastMgr(thisgroup).recvBroadcast(msg);
00057 }

void BroadcastMgr::subscribe ( BroadcastClient bc  ) 

Definition at line 60 of file BroadcastMgr.C.

References UniqueSet< Elem >::add(), BOID::broadcastSet, UniqueSet< Elem >::find(), BroadcastClient::id, and BOID::taggedMsg.

Referenced by BroadcastClient::BroadcastClient().

00060                                            {
00061   BOID *b;
00062   if (!(b = boid.find(BOID(bc.id)))) {
00063     boid.add(BOID(bc.id));
00064     b = boid.find(BOID(bc.id));
00065     b->broadcastSet = new UniqueSet<BroadcastClientElem>;
00066     b->taggedMsg = new UniqueSet<TaggedMsg>;
00067   }
00068   b->broadcastSet->add(BroadcastClientElem(&bc));
00069 }

void BroadcastMgr::unsubscribe ( BroadcastClient bc  ) 

Definition at line 72 of file BroadcastMgr.C.

References BOID::broadcastSet, UniqueSet< Elem >::del(), UniqueSet< Elem >::find(), BroadcastClient::id, UniqueSet< Elem >::size(), and BOID::taggedMsg.

Referenced by BroadcastClient::~BroadcastClient().

00072                                              {
00073   BOID *b;
00074   if ( (b = boid.find(BOID(bc.id))) ) {
00075     b->broadcastSet->del(BroadcastClientElem(&bc));
00076     if (!b->broadcastSet->size()) {
00077       delete b->broadcastSet;
00078       b->broadcastSet = 0;
00079       delete b->taggedMsg;
00080       b->taggedMsg = 0;
00081     }
00082   }
00083 }


The documentation for this class was generated from the following files:
Generated on Wed Sep 20 01:17:16 2017 for NAMD by  doxygen 1.4.7