Saturday was spent mostly on redesigning the Stockings library. It now differentiates packets and messages; apps using the stocking send messages, which are automatically compiled into packets before sending. This is done by a new Packetize thread, which monitors the message out queue and populates the packetOut queue. Incoming packets are made back into messages in a Depacketize thread. Still a few bugs to kill, and still a few features missing (notably splitting large messages across packets). Not sure 3 separate threads are really called for here, but it seemed appropriate, and hoping it will help with scalability later, especially for servers.
Of course, the end result of a long day of work is that the stockings test apps appear to work exactly like before, and the other projects which use stockings won’t compile at all with the new lib until they are rewritten as well. I hate days of programming like that, where you have nothing tangible to show for your efforts at the end of it. Couldn’t put it off anymore, though, as it was getting worse the longer I just kept using the old version, as this change had to happen eventually.
As a required detour in the redesign, I took my mutex and semaphore classes and gave them a steroids injection. They now derive from a common Synchronizer class, which provides support for waiting on multiple objects at once. Also rewrote SafeQueue to derive from semaphore, and set up the waitonmultiple functions so that the objects can return a value when obtained. None of this required much code, since in just wrapping up the windows objects, but I’m quite pleased with the results; you can wait, for example, on two queues and an event; if one of the queues fires first, the popped value from that queue is returned. These improved sync objects made synching all the new threads trivial.
Todays agenda: squash those bugs and start refactoring the mu project to work with the new lib. If all goes well, by the end of the day you won’t be able to tell anything has changed since Friday.