[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: recognizing whether a caller uses function result
- From: Sean Conner <sean@...>
- Date: Wed, 22 Feb 2023 00:28:39 -0500
It was thus said that the Great Roman Gershman once stated:
> Hello,
>
> I need to implement a custom lua function that unfortunately has some
> latency - say, it reads from disk and returns the data:
>
> With a single call it's bearable but if there is a script like
> ```
> foo();
> foo();
> foo();
> ```
>
> then the latency multiplies. Is it possible to recognize that a caller does
> not really read foo's return value in the script?
> The motivation - to batch I/O requests together in that case by returning
> from the function earlier than the I/O finishes
In general, no, it's not possible for foo() to know that its return value
is ignored. Yes, it is possible to batch I/O requests and have them run in
the background, but no, it's not portable. And there are different ways to
achieve what you want (threads doing the I/O or event driven I/O).
-spc