Skip to content

Commit fe5e210

Browse files
authored
Add id attribute for mirai (#408)
* Add id attribute for mirai * Supply R_MissingArg to request(cv =)
1 parent 37a8c21 commit fe5e210

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: mirai
33
Title: Minimalist Async Evaluation Framework for R
4-
Version: 2.4.1.9001
4+
Version: 2.4.1.9002
55
Authors@R: c(
66
person("Charlie", "Gao", , "[email protected]", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0002-0750-061X")),
@@ -27,7 +27,7 @@ BugReports: https://github.com/r-lib/mirai/issues
2727
Depends:
2828
R (>= 3.6)
2929
Imports:
30-
nanonext (>= 1.6.2.9001)
30+
nanonext (>= 1.6.2.9002)
3131
Suggests:
3232
cli,
3333
litedown

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
* New `with_daemons()` and `local_daemons()` helper functions for using a particular compute profile.
1313
This works with daemons that are already set up unlike the existing `with.miraiDaemons()` method, which creates a new scope and tears it down when finished (#360).
14+
* Each mirai now has an attribute `id`, which is a monotonically increasing integer identifier in each session.
1415

1516
#### Updates
1617

@@ -31,7 +32,7 @@
3132
+ Preserves the original condition classes and may be re-thrown as the original condition (thanks @sebffischer, #400).
3233
+ The print method includes the customary additional line break (thanks @sebffischer, #399).
3334
* A `mirai()` evaluated on an ephemeral daemon returns invisibly, consistent with other cases (#351).
34-
* Requires nanonext >= [1.6.2.9001].
35+
* Requires nanonext >= [1.6.2.9002].
3536

3637
# mirai 2.4.1
3738

R/mirai.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#' This function will return a 'mirai' object immediately.
1010
#'
1111
#' The value of a mirai may be accessed at any time at `$data`, and if yet
12-
#' to resolve, an 'unresolved' logical NA will be returned instead.
12+
#' to resolve, an 'unresolved' logical NA will be returned instead. Each mirai
13+
#' has an attribute `id`, which is a monotonically increasing integer identifier
14+
#' in each session.
1315
#'
1416
#' [unresolved()] may be used on a mirai, returning TRUE if a 'mirai' has yet to
1517
#' resolve and FALSE otherwise. This is suitable for use in control flow
@@ -419,7 +421,7 @@ stop_mirai <- function(x) {
419421
aio <- .subset2(x, "aio")
420422
!is.integer(aio) &&
421423
attr(aio, "id") > 0 &&
422-
query_dispatcher(attr(aio, "context"), c(0L, attr(aio, "id")))
424+
query_dispatcher(attr(aio, "context"), c(0L, attr(x, "id")))
423425
}
424426

425427
#' Query if a mirai is Unresolved
@@ -597,7 +599,7 @@ ephemeral_daemon <- function(data, timeout) {
597599
send_mode = 1L,
598600
recv_mode = 1L,
599601
timeout = timeout,
600-
cv = NA
602+
cv = substitute()
601603
)
602604
`attr<-`(.subset2(aio, "aio"), "sock", sock)
603605
invisible(aio)

man/mirai.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/tests.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ connection && {
7070
q / m
7171
}, m = 2L, .args = environment(), .timeout = 2000L)
7272
test_identical(call_mirai(m), m)
73+
test_type("integer", attr(m, "id"))
7374
if (!is_error_value(m$data)) test_equal(m$data, 3L)
7475
Sys.sleep(1L)
7576
`lang obj` <- quote(m + n + 2L)

0 commit comments

Comments
 (0)