Use a binary semaphore to wait for messages to be handled by external modules.

Reduces the CPU load when there are many scripts handling messages.


git-svn-id: http://voip.null.ro/svn/yate@3169 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-04-06 11:13:47 +00:00
parent f839f0bc9b
commit b7e750e8a1
1 changed files with 3 additions and 2 deletions

View File

@ -169,7 +169,7 @@ private:
bool m_accepted;
};
class MsgHolder : public GenObject
class MsgHolder : public GenObject, public Semaphore
{
public:
MsgHolder(Message &msg);
@ -910,7 +910,7 @@ bool ExtModReceiver::received(Message &msg, int id)
// other thread - unfortunately this does not work with all mutexes
// sorry, Maciek - have to do it work in Windows too :-(
while (ok) {
Thread::yield();
h.lock(Thread::idleUsec());
lock();
ok = (m_waiting.find(&h) != 0);
if (ok && tout && (Time::now() > tout)) {
@ -1246,6 +1246,7 @@ bool ExtModReceiver::processLine(const char* line)
m_chan->waitMsg(0);
m_chan->waiting(true);
}
msg->unlock();
p->remove(false);
return false;
}