abooij / sudbury

Haskell implementation of the wayland protocol
MIT License
89 stars 5 forks source link

Implement object lifetime tracker #11

Closed abooij closed 7 years ago

abooij commented 8 years ago

The (hopefully) final bug in #5 is the fact that we are not tracking object lifetime correctly. I think the elegant way to solve this is to restructure how we queue the packages for sending/receiving.

Currently, this send/receive queue is just that: a queue of WirePackages and file descriptors that get decoded into WireMessages somewhere along the way (this code is currently in Graphics.Sudbury.CABI.Client, but either this code or the solution I propose next should be available for the Haskell API as well, as a step towards solving #2). Probably the better way to set this up is to write some code that orders all packages coming in and going out, and depending on that, decides if objects should be considered alive or dead for certain operations. I'm imagining a pipeline roughly like this:

User code <-----------> MessageQueueManager <---------------> PackageQueueManager <--> domain socket
           WireMessage                       WirePackage, Fd

where MessageQueueManager sequences the incoming/outgoing packages, and makes object lifetime decisions atomically.

If users want to send/receive raw WirePackages, then this pattern still allows that: simply don't use the MessageQueueManager, or insert something between that and the PackageQueueManager.

The complicating factor here is that we'd need to teach MessageQueueManager about decoding WirePackages.

(names may change)

abooij commented 8 years ago

Beginnings have now been made in the form of 3f8b420.