VIbe-d fiber question

WebFreak001 d.forum at webfreak.org
Mon Mar 13 20:54:14 UTC 2023


On Monday, 13 March 2023 at 06:24:15 UTC, Tristan Brice Velloza 
Kildaire wrote:
> [...]
>
> However, here is the snatch (and consequently where my question 
> comes in). Because we are accepting connections by virtue of a 
> web socket handler which is called on web socket connections to 
> the `/` route, I can obviously handle each client by doing some 
> work in a loop, then when I am done calling `this.yield()` 
> where `this` is a `Connection : Fiber` (custom type of mine), 
> this then saving the stack context, the instruction address 
> etc. for later resumption with `conn1.call()`.
>
> [...]

you should use vibe.d's fiber's (runTask / new task is default 
for every connection handler) and then use vibe.d's `yield` 
function instead. It also yields on all vibe.d I/O APIs, e.g. 
also websocket send/receive.

Instead of pre-connection-accept, you simply do you work before 
your actual code. You can use runTask if you need to branch off 
things, but it's easier to just do all the work in your websocket 
handler.


More information about the Digitalmars-d mailing list