zeroshade commented on PR #43632:
URL: https://github.com/apache/arrow/pull/43632#issuecomment-2284477412
@westonpace I completely forgot to address the other suggestion where you
*did* put the waker directly into the interface lol
```c
struct Waker {
// Signal to the producer that more data is available, the consumer shall
release any resources
// associated with the waker after this method is called. The producer
shall not call any other
// methods after calling this method.
//
// The producer must always call this method even if an error is
encountered (in which case the
// error will be reported on the following call to `get_next`).
void wake(Waker* waker);
void* private_data;
};
struct ArrowAsyncDeviceArrayStream {
// Callback to get the next array
// (if no error and the array is released, the stream has ended)
//
// Return value: 0 if successful, an `errno`-compatible error code
otherwise.
//
// If EWOULDBLOCK is returned then the producer is not ready to generate
more data. If the
// producer returns this value then the producer takes ownership of
`waker` and is responsible
// for calling `wake` when more data is available. If any other value is
returned then the producer
// shall ignore `waker` and never call any methods on it.
//
// If successful, the ArrowDeviceArray must be released independently from
the stream.
int (*get_next)(struct ArrowAsyncDeviceArrayStream* self, Waker* waker,
struct ArrowDeviceArray* out);
// The rest is identical to `ArrowDeviceArrayStream`
ArrowDeviceType device_type;
const char* (*get_last_error)(struct ArrowAsyncDeviceArrayStream* self);
void (*release)(struct ArrowAsyncDeviceArrayStream* self);
void* private_data;
};
```
I guess I still have the same questions as before though. Isn't the waker
provided *by* the consumer for the producer to signal to the *consumer* that
data is available? not the other way around?
The original idea and semantics here were that the
`ArrowAsyncDeviceArrayStream` is constructed by the consumer and given to the
producer, given the comments you've put here it seems like this is the other
way around now? The producer still provides the struct, and the consumer calls
`get_next` providing the `waker`. Do I have that right? What happens if
`get_next` is called again before `wake` is called on the waker? Are we
defining that `get_next` must not be called until `wake` is called? The
semantics are a bit confusing to me here as far as what you're proposing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]