Posted 11 February 2013 - 02:38 PM
Hello,
Would it be possible that suubsquent calls to mountFixedDir with the same exacts parameters, instead of creating a new directory, increase an internal reference counter, which would be decreased by unmount and detach?
Let me explain.
Most of the time when writing peripheral, we may need to add a new api to "rom/apis" in the form
Right now the only way to deal with it is to store the list of devices for a given computer and when a device is disconnected, ask another one to mount the directory.
So here is how it could work when a computer is plugged with 3 similar devices:
Would it be possible that suubsquent calls to mountFixedDir with the same exacts parameters, instead of creating a new directory, increase an internal reference counter, which would be decreased by unmount and detach?
Let me explain.
Most of the time when writing peripheral, we may need to add a new api to "rom/apis" in the form
computer.mountFixedDir("rom/apis/foobar", "mods/foobar/foobar.lua", false, 0)
The issue is that if you have 5 peripherals around, you get rom/apis/foobar, foobar2, etc… and when removing the first peripheral who tried to mount, you lose rom/apis/foobarRight now the only way to deal with it is to store the list of devices for a given computer and when a device is disconnected, ask another one to mount the directory.
So here is how it could work when a computer is plugged with 3 similar devices:
- Device 1 attach: call mountFixedDir on rom/apis/foobar with mods/foobar.lua as a source, create a counter with ref count set to 1
- Device 2 attach: makes the same call with the same parameters, ref count increase to 2
- Device 3 attach: makes a slightly different call (like read only has changed or the source is not the same), that creates rom/apis/foobar2 with ref count set to 1
- Device 1 detach: we decrease the ref count on rom/apis/foobar by one, we still have 1 ref going on
- Device 3 detach: ref count on rom/apis/foobar2 drops to 0, unmount
- Device 2 detach: ref count on rom/apis/foobar drops to 0, unmount