Skip to content

Commit

Permalink
Take advantage of the ability to await send()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Dec 6, 2024
1 parent d46636a commit 39bed0e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions modules/http/chan_commands.pike
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,16 @@ __async__ mapping(string:mixed) http_request(Protocols.HTTP.Server.Request req)
vars["$$"] = u->display_name;
vars["{uid}"] = (string)person->uid; //Will be "0" if no UID known
array capture = ({ });
c->_send_with_catch(person, message, vars, ([
await(c->_send_with_catch(person, message, vars, ([
"users": (["": (string)person->uid]),
"simulate": lambda(string m) {capture += ({m});},
]));
])));
mapping stats = ([]);
int num = (int)req->variables->num || 100;
for (int i = 0; i < num; ++i) c->_send_with_catch(person, message, vars, ([
for (int i = 0; i < num; ++i) await(c->_send_with_catch(person, message, vars, ([
"users": (["": (string)person->uid]),
"simulate": lambda(string m) {stats[m]++;},
]));
sleep(2); //Hack upon hack: Wait till it's probably done sending.*/
])));
array lines = indices(stats), counts = -values(stats)[*];
sort(counts, lines);
int tot = 0;
Expand Down

0 comments on commit 39bed0e

Please sign in to comment.