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

Improve on_progress #68

Merged
merged 11 commits into from
Feb 7, 2024
Merged

Improve on_progress #68

merged 11 commits into from
Feb 7, 2024

Conversation

noteflakes
Copy link
Contributor

@noteflakes noteflakes commented Feb 5, 2024

This PR introduces some improvements to the progress handler functionality:

  • All settings are optional, passed through keyword arguments.
  • Add tick parameter.
  • Add mode: normal, once, at least once.
  • Add global Extralite.on_progress method for setting global progress handler behaviour.

The tick parameter is used to control the granularity of the progress
handler. This is the value passed to sqlite3_progress_handler. The
period parameter is used to control how often the progress handler proc
is called. So, a period of 1000 and a tick of 10 will cause the internal
progress handler callback to be called every 10 SQLite VM instructions,
but the proc will be called only every 1000 (cumulative) VM
instructions.

The different modes:

  • normal: the progress handler proc is called only on SQLite progress.
  • once: the progress handler proc is called only when preparing to run a
    query.
  • at least once: the progress handler proc is when preparing to run a
    query, and on SQLite progress.

Some examples:

# tick default value: 10
db.on_progress(1000) { snooze }


db.on_progress(mode: :once) { snooze }

Extralite.on_progress(mode: :at_least_once, period: 100, tick: 5) { snooze }

- Add tick parameter.
- Add mode: normal, once, at least once

The tick parameter is used to control the granularity of the progress
handler. This is the value passed to sqlite3_progress_handler. The
period parameter is used to control how often the progress handler proc
is called. So, a period of 1000 and a tick of 10 will cause the internal
progress handler callback to be called every 10 SQLite VM instructions,
but the proc will be called only every 1000 (cumulative) VM
instructions.

The different modes:

- normal: the progress handler proc is called only on SQLite progress.
- once: the progress handler proc is called only when preparing to run a
  query.
- at least once: the progress handler proc is when preparing to run a
  query, and on SQLite progress.
@noteflakes noteflakes merged commit b114a39 into main Feb 7, 2024
24 checks passed
@noteflakes noteflakes deleted the better_on_progress branch February 9, 2024 07:20
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.

1 participant