00001
00002
00003
00004
00005 #ifdef __GNUG__
00006 # pragma implementation "RegistryDispatcherGlue.h"
00007 #endif
00008
00009 #include "UniEvent/RegistryDispatcherGlue.h"
00010 #include "UniEvent/Dispatcher.h"
00011 #include "UniEvent/UnixEventRegistry.h"
00012
00013 namespace strmod {
00014 namespace unievent {
00015
00016 RegistryDispatcherGlue::RegistryDispatcherGlue(Dispatcher *disp,
00017 UnixEventRegistry *ureg)
00018 : disp_(disp), ureg_(ureg),
00019 emptyev_(new EmptyEvent(this)), busyev_(new BusyEvent(this))
00020 {
00021 if (disp_)
00022 {
00023 disp_->onQueueEmpty(emptyev_);
00024 disp_->addBusyPollEvent(busyev_);
00025 }
00026 }
00027
00028 RegistryDispatcherGlue::~RegistryDispatcherGlue()
00029 {
00030 emptyev_->parentGone();
00031 busyev_->parentGone();
00032 }
00033
00034 void RegistryDispatcherGlue::doBusyAction()
00035 {
00036 if (disp_)
00037 {
00038 disp_->addBusyPollEvent(busyev_);
00039 }
00040 if (ureg_)
00041 {
00042 ureg_->doPoll(false);
00043 }
00044 }
00045
00046 void RegistryDispatcherGlue::doQEmptyAction()
00047 {
00048 if (disp_)
00049 {
00050 disp_->onQueueEmpty(emptyev_);
00051 }
00052 if (ureg_)
00053 {
00054 ureg_->doPoll(true);
00055 }
00056 }
00057
00058 void RegistryDispatcherGlue::dispatcher(Dispatcher *disp)
00059 {
00060 if (disp != disp_)
00061 {
00062 emptyev_->parentGone();
00063 emptyev_.ReleasePtr();
00064 busyev_->parentGone();
00065 busyev_.ReleasePtr();
00066
00067 disp_ = disp;
00068 emptyev_ = new EmptyEvent(this);
00069 busyev_ = new BusyEvent(this);
00070
00071 if (disp_)
00072 {
00073 disp_->onQueueEmpty(emptyev_);
00074 disp_->addBusyPollEvent(busyev_);
00075 }
00076 }
00077 }
00078
00079 }
00080 }