inst/doc/multithreading.R

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

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

## -----------------------------------------------------------------------------
# Check the current setting (default: 1)
a5_get_threads()

# Use 4 threads
a5_set_threads(4)
a5_get_threads()

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

## -----------------------------------------------------------------------------
old <- a5_set_threads(4)
# ... parallel work ...
a5_set_threads(old)

## ----eval = FALSE-------------------------------------------------------------
# cells <- a5_grid(c(-10, 50, 10, 60), resolution = 12)
# length(cells)
# #> [1] 704259
# 
# a5_set_threads(1)
# system.time(a5_cell_to_boundary(cells, format = "wkt"))
# #>   user  system elapsed
# #>  3.124   0.000   3.122
# 
# a5_set_threads(8)
# system.time(a5_cell_to_boundary(cells, format = "wkt"))
# #>   user  system elapsed
# #> 6.195   1.289   1.667

Try the a5R package in your browser

Any scripts or data that you put into this service are public.

a5R documentation built on March 26, 2026, 5:10 p.m.