Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Make files close on drop #69

Open
thejpster opened this issue Aug 18, 2019 · 1 comment
Open

Make files close on drop #69

thejpster opened this issue Aug 18, 2019 · 1 comment

Comments

@thejpster
Copy link
Owner

The immutable API for embedded-sdmmc is problematic, because the File objects hold a reference to their parent filesystem - which is in a big context structure. You then can't, say, write to the UART while holding an open File (which is nonsense).

Moving the disk controller to its own global structure with its own lock helps, but you can still only hold files while you have the lock open. You couldn't, for example, store an open file, release the disk lock and then come back to the file later on.

I propose instead, that Monotron creates its own Handle type which close themselves on Drop. They would implement the basic read/write/seek/close operations, and any access on a file Handle would temporarily grab the lock for the disk, or any access on a uart Handle would temporarily grab the lock for the UART.

This can be implemented with the standard mutable embedded-sdmmc API.

@thejpster
Copy link
Owner Author

This is related to #61.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant