## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(a5R)

## -----------------------------------------------------------------------------
a5_threads() # the default: 1

a5_threads(2)
a5_threads()

## ----include = FALSE----------------------------------------------------------
a5_threads(1)

## -----------------------------------------------------------------------------
set.seed(1)
cells <- a5_lonlat_to_cell(runif(1e4, -180, 180), runif(1e4, -80, 80), 10)
boundaries <- with(a5_threads(2), {
  a5_cell_to_boundary(cells)
})
a5_threads()

## ----eval = FALSE-------------------------------------------------------------
# cells <- a5_uncompact(a5_polygon_to_cells(wk::rct(-10, 50, 10, 60), resolution = 12))
# length(cells)
# #> [1] 694889
# 
# a5_threads(1)
# system.time(a5_cell_to_boundary(cells))
# #>    user  system elapsed
# #>   0.952   0.005   0.956
# 
# a5_threads(8)
# system.time(a5_cell_to_boundary(cells))
# #>    user  system elapsed
# #>   1.206   0.009   0.248

