Mir

Code review comment for lp:~vanvugt/mir/wait-result

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

1. The assertion at the start of your comment is incorrect. As demonstrated by this branch. A single function call is obviously less "painful" than writing callbacks. Admittedly this counts as opinion, but I think you'd probably find 99% of developers agree that a single function call that avoids the need for callbacks is preferable.

2. "in the case of waiting for a construction it's a duplication of foo_is_valid()". Yep foo_is_valid would become unnecessary, which is a good thing. That's one less function that clients need to bother calling.

3. "without the ability to query the error condition". Incorrect. I already documented future plans for that:
376 + // Suggested future uses:
377 + // const char* error;

For example (bug 1431190):
   int err = mir_wait_for_error(wait_handle);
   fprintf(stderr, "Thingy failed due to: %s\n", strerror(err));
or (without fixing bug 1431190):
   const char *err = mir_wait_for_error(wait_handle);
   fprintf(stderr, "Thingy failed due to: %s\n", err);

Another value in the approach here is that it solves the thread safety problem of querying errors we have today (mir_X_get_error_message). If you have multiple threads operating on a single Mir object then our current API will leak incorrect error values between threads. The approach proposed here will not.

« Back to merge proposal