Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensor objects fire 'change' event considering their own frequency hint #210

Merged
merged 3 commits into from
Jun 26, 2017

Conversation

pozdnyakov
Copy link

@pozdnyakov pozdnyakov commented May 23, 2017

Fixes #152. Each Sensor instance fires 'change' event considering its individual
frequency hint. Thus we achieve that appearance of a new Sensor instance with a
higher frequency hint does not affect the 'onchange' notification of the existing
Sensor instances of the same type.


Preview | Diff

@pozdnyakov
Copy link
Author

@tobie @anssiko please take a look. Here is the extract from #197 , should be easier to review :)

@anssiko anssiko changed the title Sensor obects have their own a reading copies. Sensor objects have their own a reading copies. May 24, 2017
@anssiko anssiko changed the title Sensor objects have their own a reading copies. Sensor objects have their own reading copies May 24, 2017
@anssiko anssiko self-requested a review May 24, 2017 09:55
@pozdnyakov
Copy link
Author

gentle ping for review

@tobie
Copy link
Member

tobie commented May 24, 2017

I won't be able to get to this right away. And I'd like to review it personally before merging it in. Sorry.

Copy link
Member

@anssiko anssiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one issue identified.

index.bs Outdated
1. Abort these steps.
1. Let |reportingInterval| be the result of 1 / |reportingFrequency|.
1. Let |timestampDelta| be the result of [=latest reading=]["timestamp"] - |lastReportedTimestamp|.
1. If |timestampDelta| is less than or equal to |reportingInterval|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is less than or equal to/is greater than or equal to/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch!

index.bs Outdated
1. Abort these steps.
1. Let |reportingFrequency| be result of invoking the [=Find the reporting frequency of a Sensor=]
abstract operation.
1. If |reportingFrequency| is not set

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find the reporting frequency of a Sensor algorithm always returns something, so, branch If |reportingFrequency| is not set should never be executed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Find the reporting frequency of a Sensor operation can return null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) not set =! set to null
Maybe If |reportingFrequency| is null ? wdyt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)

Copy link

@alexshalamov alexshalamov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pozdnyakov pozdnyakov changed the title Sensor objects have their own reading copies Sensor objects fire 'change' event considering their own frequency hint May 29, 2017
@pozdnyakov pozdnyakov requested a review from anssiko May 29, 2017 14:04
index.bs Outdated
passing it |sensor_instance| as argument.
1. Abort these steps.
1. Let |deferUpdateTime| be the result of |reportingInterval| - |timestampDelta|.
1. User agent must defer queueing a task to run the [=Notify Sensor Object about new reading=] abstract

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a way to cancel this, e.g., if stop() is called?

Queuing task == sensor_task_source.task_queue.add(task);
Do we need to save 'deferred notify' and then, if stop is called, we would not queue a task?

Copy link
Member

@anssiko anssiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the delta to the previous, LGTM with minor nits.

index.bs Outdated
@@ -1175,6 +1175,9 @@ Gets the {{Error}} object passed to {{SensorErrorEventInit}}.
value of |reading| to see if there's a change
that needs to be propagated.
1. Unset |sensor|’s [=reporting flag=].
1. [=set/For each=] |s| of |activated_sensors|,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To iterate over a list, use "For each X in Y".

index.bs Outdated
@@ -1175,6 +1175,9 @@ Gets the {{Error}} object passed to {{SensorErrorEventInit}}.
value of |reading| to see if there's a change
that needs to be propagated.
1. Unset |sensor|’s [=reporting flag=].
1. [=set/For each=] |s| of |activated_sensors|,
1. Invoke the [=Report Latest Reading updated=] abstract operation,
passing it |s| as argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as an argument

@pozdnyakov
Copy link
Author

@tobie, could you PTAL ? this implements the consensus approach from #152

@tobie
Copy link
Member

tobie commented May 31, 2017

@pozdnyakov: I did take a look. I'd like to clean-up parts of the spec before integrating this. I also don't think this is the cleanest way to do this, tbh. Let me come back to it later.

Copy link

@alexshalamov alexshalamov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the specification has clear definition for sensor task source, I think this PR can be merged.

@anssiko
Copy link
Member

anssiko commented Jun 22, 2017

LGTM.

@anssiko
Copy link
Member

anssiko commented Jun 26, 2017

@alexshalamov @pozdnyakov, there has been plenty of time (>1 month) for the group to review this PR, and all feedback that suggests concrete changes have been incorporated. You should be able to merge this now.

Mikhail Pozdnyakov added 2 commits June 26, 2017 12:43
…its individual

frequency hint. Thus we achieve that  appearance of a new Sensor instance with a
higher frequency hint does not affect the 'onchange' notification of the existing
Sensor instances of the same type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants