linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Winch <sunt.un.morcov@gmail.com>
To: Helmut Grohne <helmut.grohne@intenta.de>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Bartosz Golaszewski <bartekgola@gmail.com>
Subject: Re: [libgpiod] cxx bindings: time_point vs duration
Date: Thu, 22 Oct 2020 12:09:42 +0300	[thread overview]
Message-ID: <CAFhCfDY5JS4WB=0OFdjYGeuRobuMPKkjeir29M6EOSe9zVufVw@mail.gmail.com> (raw)
In-Reply-To: <20201022063935.GA23978@laureti-dev>

> You're arguing that a std::chrono::steady_clock::time_point is not a good match due to its undefined ratio.

std::chrono::steady_clock::time_point is not a good match for the
reasons you have quoted.

> That can be fixed by using a clock with a well-defined ratio.

I agree that defining a clock with a suitable ratio would remove the
problems faced when using a clock with an undefined ratio.

> The key here is that while you can easily convert your duration to a
> time_point, a duration is conceptually the wrong thing to use.

I agree that the timestamp value is conceptually a time_point.

> If you are not satisfied with the resolution
> guarantuee of steady_clock, just make your own clock. Doing so results
> in a lot of type safety. For instance, if you accidentally compute a
> difference between a system_clock::time_point and a gpiod timestamp,
> using a duration would just work whereas a time_point would result in a
> compilation failure.

I also agree with the excellent point you raise regarding type safety
and preferring compile-time errors to runtime errors.  Where possible,
care should be taken to mitigate or eradicate the potential for these
types of runtime bug.

The problem is, the solution you were suggesting to be suitable was
not (in its current form).  There are numerous issues with the
proposal above, which require further discussion.  As has been pointed
out, changes were made to the char dev in Linux 5.7 such that line
events are timestamped using the system 'monotonic' clock as opposed
to the 'realtime' clock.  So now the clock in which that timestamp is
relative to is kernel version dependent.  The ability to configure
this will become available in the next version of the kernel, but the
problem of which system clock is being used for older kernels will
still remain.

I rebuffed the suggestion in the manner that I did as the change would
have caused issues.  I completely understand and agree with the key
rationale behind the proposed change.  With further discussion, a
suitable solution might be found, but it requires further thought.
What I did not want to see happen is the change as currently proposed
be applied and cause issues in the future.

That being said, let's continue this discussion to see what can be
done (and preferably without any p*ssing contest).  The remainder of
this week is no good for me, but would you be available to discuss
potential solutions next week, Helmut?

Jack

  reply	other threads:[~2020-10-22  9:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15  8:38 [libgpiod] cxx bindings: time_point vs duration Helmut Grohne
2020-10-15  9:26 ` Bartosz Golaszewski
2020-10-15  9:35   ` Helmut Grohne
2020-10-15 10:05     ` Bartosz Golaszewski
2020-10-15 10:57       ` Helmut Grohne
2020-10-15 11:43         ` Bartosz Golaszewski
2020-10-15 12:13           ` Helmut Grohne
2020-10-15 12:16             ` Bartosz Golaszewski
2020-10-21 13:57               ` Jack Winch
2020-10-21 14:35                 ` Jack Winch
2020-10-21 15:14                 ` Bartosz Golaszewski
2020-10-21 15:44                   ` Jack Winch
2020-10-22  6:39                 ` Helmut Grohne
2020-10-22  9:09                   ` Jack Winch [this message]
2020-10-22  9:35                     ` Bartosz Golaszewski
2020-10-22  9:47                       ` Jack Winch
2020-10-22 11:55                         ` Bartosz Golaszewski
2020-10-22 12:22                           ` Jack Winch
2020-10-23 16:22                             ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFhCfDY5JS4WB=0OFdjYGeuRobuMPKkjeir29M6EOSe9zVufVw@mail.gmail.com' \
    --to=sunt.un.morcov@gmail.com \
    --cc=bartekgola@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=helmut.grohne@intenta.de \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).