Wherefore callbacks?
habemus-papadum opened this issue · 3 comments
Hi,
the current design uses callbacks to communicate the results of operations back to the fuse daemon, e.g.: the cb
in readdir: function (path, cb) ...
.
Can you explain the rationale for this, rather than, say having the operations return values e.g.
readdir: function (path) { return ['file1'];}
The python bindings for fuse seems to choose that approach.
For instance is it ever correct to call a callback more than once for a given operation? Also can a callback be used after the operation notification has completed? (e.g. readdir
returns without calling cb
, and at a later point cb
is called with proper data)
A 'yes' to either question would clarify the current design, however, best would be examples demonstrating the possibilities.
Cheers! nehal
Python is a blocking language, while Javascript not, so operations are asynchronous. They work the same way, only that in Python the execution will stop until the called functions return a value, and in Javascript they continue, so instead of returning the result, you pass it to the callback function.
python learned async/await
a while back and has known yield
for a very long time....
But, to keep it simple -- is it valid to cb
more than once for any operation?
But, to keep it simple -- is it valid to cb more than once for any operation?
Depends of the library you are using, but usually (like in this case) not.