Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 0bed3ba

Browse files
authored
Merge pull request #59 from daniel0611/real-loop
Implement a real loop for plugins
2 parents 32c96b1 + 20324fe commit 0bed3ba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/scala/org/codeoverflow/chatoverflow/instance/PluginInstance.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,14 @@ class PluginInstance(val instanceName: String, pluginType: PluginType) extends W
163163
// Execute loop, if an interval is set
164164
if (plugin.get.getLoopInterval > 0) {
165165
while (!threadStopAfterNextIteration) {
166+
val startTime = System.currentTimeMillis()
167+
166168
plugin.get.loop()
167-
Thread.sleep(plugin.get.getLoopInterval)
169+
170+
val execTime = System.currentTimeMillis() - startTime
171+
val sleepTime = plugin.get.getLoopInterval - execTime
172+
if (sleepTime > 0)
173+
Thread.sleep(sleepTime)
168174
}
169175
}
170176

0 commit comments

Comments
 (0)