00001 #include "waitqd.h" 00002 00003 /* readonly */ 00004 CkChareID _waitqd_qdhandle; 00005 00006 extern "C" void CkWaitQD(void) { 00007 CProxy_waitqd_QDChare qdchareproxy(_waitqd_qdhandle); 00008 qdchareproxy.waitQD(); 00009 } 00010 00011 waitqd_QDChare::waitqd_QDChare(CkArgMsg *m) { 00012 waitStarted = false; 00013 threadList = 0; 00014 _waitqd_qdhandle = thishandle; 00015 delete m; 00016 } 00017 00018 void waitqd_QDChare::waitQD(void) { 00019 if (waitStarted) { 00020 CdsFifo_Enqueue((CdsFifo)threadList, (void *)CthSelf()); 00021 } else { 00022 waitStarted = true; 00023 threadList = (void*) CdsFifo_Create(); 00024 CdsFifo_Enqueue((CdsFifo) threadList, (void *)CthSelf()); 00025 CkStartQD(CkIndex_waitqd_QDChare::onQD((CkQdMsg*)0), &thishandle); 00026 } 00027 CthSuspend(); 00028 } 00029 00030 void waitqd_QDChare::onQD(CkQdMsg *ckqm) { 00031 CthThread pthr; 00032 while(!CdsFifo_Empty((CdsFifo) threadList)) { 00033 pthr = (CthThread)CdsFifo_Dequeue((CdsFifo) threadList); 00034 CthAwaken(pthr); 00035 } 00036 CdsFifo_Destroy((CdsFifo) threadList); 00037 threadList = 0; 00038 waitStarted = false; 00039 delete ckqm; 00040 } 00041 00042 #include "waitqd.def.h"