Added msleep function that permits sleeping when handling a message.

git-svn-id: http://yate.null.ro/svn/yate/trunk@6520 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
oana 2021-09-24 13:24:10 +00:00
parent 808bc77a0f
commit ca208774e0
2 changed files with 18 additions and 0 deletions

View File

@ -211,6 +211,7 @@
; parameters are taken from the old message but placed in the new one
; echo, output - displays that line after making substitutions
; debug - displays line as a debug after making substitutions
; msleep - sleep for the specified number of milliseconds
; noop - no action but evaluates rest of target for side effects
; { - starts a block that ends on another line with }
; The @jump, @goto, @include and @call forms suppress warning if missing target

View File

@ -1058,6 +1058,23 @@ bool RegexConfig::oneContext(Message &msg, String &str, const String &context, S
val.length(),i+1,n->name().c_str(),context.c_str());
ret = val;
}
else if (val.startSkip("msleep")) {
val.trimBlanks();
if (!val.null()) {
NDebug("RegexRoute",DebugAll,"Sleeping for %s milliseconds by rule #%u '%s' in context '%s'",
val.c_str(),i+1,n->name().c_str(),context.c_str());
uint64_t t = val.toInt64(0,0,0);
uint64_t count = t / Thread::idleMsec();
uint64_t rest = t % Thread::idleMsec();
for (uint64_t i = 0; i < count; i++) {
Thread::idle();
if (Thread::check(false))
break;
}
if (rest && !Thread::check(false))
Thread::msleep(rest);
}
}
else {
DDebug("RegexRoute",DebugAll,"Returning '%s' for '%s' in context '%s' by rule #%u '%s'",
val.c_str(),str.c_str(),context.c_str(),i+1,n->name().c_str());