From: Patrick E. <pa...@pa...> - 2004-03-31 21:35:10
|
I have a few comments that I'd like to get out of my head. The fewer threads that we need to create, the better. Threads are a proven source of race conditions and other crazy bugs. I agree with Ousterhout in his paper on threads (Google knows where to find it). Though threads appear simple, it's not an easy task to avoid all synchronization bugs. Debugging threaded code is also a pain. I realize that we may need threads to handle some backend tasks, but those should be well defined and accessed only through properly synchronized interfaces. In my opinion, file operations during routine operation of the program should consist mostly of sequential reads and writes that append to the end of files. These are both fast operations. I'm not sure what level of audio support we want, but as to handling midi, I envision it as follows. When playing midi, it's all played back straight from memory. MIDI data is small and there's no need to stream it off disk. When recording midi, it's temporarily stored to memory. When the "operation" is complete, it's stored to disk. Note that an operation could consist of recording a section, doing a cut or paste operation, quantizing, or anything like that. I see that there are two seperate issues to deal with in keeping unsaved data safe: 1. Handling program crashes. 2. Handling computer crashses. The first issue shouldn't exist, but I realize it might. Simplicity is a powerful weapon in combatting #1. Signal handlers can also be used to perform emergency saves. The second issue can only really be dealt with by writing as we go, but how do we write efficiently as we go? Well, we can use the same technology that filesystems use. We append unsaved data to a journal. When the user requests a save, the updates in the journal are added to the main file. When the journal is empty, the old main file is removed and replaced with the new one. It is much easier to do this operation atomically on a single file, as it's just a rename OS call. In my opinion, a single file plus a journal file provides the maximum in safety and simplicity. The same format used for the journal can be used to provide unlimited undo. Patrick |