00001 // File: evmpool.C 00002 // EventMsgPool: facility for reusing event messages 00003 // Last Modified: 5.29.01 by Terry L. Wilmarth 00004 00005 #include "charm++.h" 00006 #include "pose.h" 00007 #include "evmpool.def.h" 00008 00009 CkGroupID EvmPoolID; 00010 00011 // Returns number of messages in pool idx 00012 int EventMsgPool::CheckPool(int idx) 00013 { 00014 if (idx < numPools) 00015 return msgPools[idx].numMsgs; 00016 else return MAX_POOL_SIZE; 00017 } 00018 00019 // Returns a message from pool idx; decrements the count 00020 void *EventMsgPool::GetEventMsg(int idx) 00021 { 00022 msgPools[idx].numMsgs--; 00023 return msgPools[idx].msgPool[msgPools[idx].numMsgs]; 00024 } 00025 00026 // Puts a message in pool idx; increments the count 00027 void EventMsgPool::PutEventMsg(int idx, void *msg) 00028 { 00029 msgPools[idx].msgPool[msgPools[idx].numMsgs] = msg; 00030 msgPools[idx].numMsgs++; 00031 }