zap icon indicating copy to clipboard operation
zap copied to clipboard

Tasks and Nodes

Open oXis opened this issue 1 year ago • 1 comments

Hi,

I'm trying to understand the code and I was wondering. What is the relation between a Task and a Node. I don't understand why tasks have nodes members. Is it because Queue and Buffer take Node structs instead of Tasks?

What is the rationale behind that design choice?

My understanding is as follows: I see that in async.zig you create a wrapper around a Task with a frame member. Is wrapping tasks into our own structs the way to go to use your thread pool? And in that case, maybe it's why you are using Nodes, because you cannot have knowledge of the "wrapping struct" when dealing with popping or pushing into Queue/Buffer.

I hope I'm clear... and sorry to dig up an old project of yours xD

oXis avatar Mar 06 '24 20:03 oXis

Is wrapping tasks into our own structs the way to go to use your thread pool?

Yea, this is the core idea behind intrusive data structures. Queueing was written in a similar way so that it could be in its own file, with Task using Node intrusively.

kprotty avatar Mar 08 '24 16:03 kprotty