Skip to content

Commit 83d03e2

Browse files
committed
Poll for changes independently from websockets
If `--action`s are passed to the app, a worker will be started in background in order to poll for changes and execute those actions, so that this happens independently from the notifications service. Decreases polling interval from 500ms to 200ms. Fixes #9. Actions will also get executed when there are no active websocket connections.
1 parent 7aad9b7 commit 83d03e2

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

source/reloadedvibes/app.d

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,18 @@ int main(string[] args)
127127
// Initial execution
128128
// Since the action is usually some preprocessor or something,
129129
// it should also get executed on application launch
130-
doInit ~= { stdout.writeln("\nPre-executing actions..."); awcl.notify(); };
131-
132-
if (optDisableService)
133-
{
134-
doInit ~= {
135-
runTask(delegate() @trusted {
136-
while (true)
137-
{
138-
awcl.query();
139-
sleep(dur!"msecs"(500));
140-
}
141-
});
142-
};
143-
}
130+
doInit ~= {
131+
stdout.writeln("\nPre-executing actions...");
132+
awcl.notify();
133+
134+
runTask(delegate() @trusted {
135+
while (true)
136+
{
137+
awcl.query();
138+
sleep(dur!"msecs"(200));
139+
}
140+
});
141+
};
144142
}
145143

146144
// -- Webserver

source/reloadedvibes/server.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ HTTPListener registerService(Socket s, Watcher w)
7676
ws.send("ReloadedVibes::Trigger;");
7777
}
7878
}
79-
sleep(dur!"msecs"(500));
79+
sleep(dur!"msecs"(200));
8080
}
8181
while (ws.connected);
8282

0 commit comments

Comments
 (0)