Skip to content

Conversation

@mgyoo86
Copy link
Collaborator

@mgyoo86 mgyoo86 commented Dec 2, 2025

Summary

Exports checkpoint!/rewind! functions and adds direct TypedPool access for users who need manual pool state management.

Changes

  • Export: checkpoint! and rewind! are now part of the public API
  • New API: Direct TypedPool access via checkpoint!(tp::TypedPool) and rewind!(tp::TypedPool)
  • Refactor: Type-specific methods now delegate to TypedPool methods (DRY principle)
  • Tests: 12 new tests covering direct usage and delegation

Usage

using AdaptiveArrayPools

# Public API - no import needed
pool = AdaptiveArrayPool()
checkpoint!(pool)
# ... work ...
rewind!(pool)

# Low-level TypedPool access (advanced)
tp = get_typed_pool!(pool, Float64)
checkpoint!(tp)  # Direct, minimal overhead
# ... work ...
rewind!(tp)

Design Decisions

  • ✅ Generic no-arg checkpoint!()/rewind!() omitted to avoid namespace pollution
  • ✅ Users doing manual management already have pool references
  • ✅ TypedPool methods enable performance-critical scenarios

Testing

All 435 tests pass, including 12 new tests for:

  • Direct TypedPool checkpoint/rewind
  • Nested state management
  • Delegation correctness

Enable manual pool management by exporting checkpoint!/rewind! functions
and adding direct TypedPool access methods.

Changes:
- Export checkpoint! and rewind! in public API
- Add checkpoint!(tp::TypedPool) and rewind!(tp::TypedPool) for low-level access
- Refactor type-specific methods to delegate to TypedPool methods (DRY principle)
- Add comprehensive tests for TypedPool direct usage and delegation

This allows users to manually manage pool state without importing, while
maintaining clean implementation through method delegation. Generic no-arg
methods were intentionally omitted to avoid namespace pollution.

Related: #feat/cache_nd_view
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.65%. Comparing base (c1ba600) to head (b4fdea2).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #3      +/-   ##
==========================================
+ Coverage   95.63%   95.65%   +0.02%     
==========================================
  Files           6        6              
  Lines         412      414       +2     
==========================================
+ Hits          394      396       +2     
  Misses         18       18              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR exports checkpoint! and rewind! functions to make them part of the public API and adds direct TypedPool access methods for advanced manual pool state management. The changes support both high-level pool management and low-level, performance-critical scenarios where users have direct TypedPool references.

  • Exports checkpoint! and rewind! (previously required explicit import)
  • Adds new checkpoint!(tp::TypedPool) and rewind!(tp::TypedPool) methods for direct TypedPool access
  • Refactors type-specific methods to delegate to TypedPool methods, following DRY principle

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/AdaptiveArrayPools.jl Exports checkpoint! and rewind! functions, removing prior comment about minimal API
src/core.jl Adds TypedPool-specific checkpoint/rewind methods with documentation and refactors existing type-specific methods to delegate
test/test_state.jl Adds comprehensive tests for direct TypedPool checkpoint/rewind functionality, nested state management, and delegation verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Update checkpoint!(tp::TypedPool) and rewind!(tp::TypedPool) docstrings
to clearly mark them as internal implementation details and guide users
to the public checkpoint!(pool, Type) API instead.

This resolves documentation confusion where users might try to use
get_typed_pool! (which requires explicit import) instead of the
exported type-specific checkpoint!/rewind! methods.

Changes:
- Add "Internal API" warning admonition to TypedPool method docs
- Replace get_typed_pool! example with public API recommendation
- Remove get_typed_pool! from "See also" references
- Guide users to checkpoint!(pool, Type) for manual management
@mgyoo86
Copy link
Collaborator Author

mgyoo86 commented Dec 2, 2025

Update

The following is the correct pattern using public APIs:

using AdaptiveArrayPools

# Public API - no import needed
pool = AdaptiveArrayPool()
checkpoint!(pool)
# ... work ...
rewind!(pool)

# Type-specific (less overhead, only for specific types)
checkpoint!(pool, Float64)
# ... work ...
rewind!(pool, Float64)

@mgyoo86 mgyoo86 merged commit ebb62fb into master Dec 2, 2025
8 checks passed
@mgyoo86 mgyoo86 deleted the feat/export-checkpoint-rewind branch December 2, 2025 23:23
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