Skip to content

Commit

Permalink
deprecate strcat and update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed May 30, 2024
1 parent 59d31cc commit 9b91369
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 38 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#### Updates

* `recv_aio()` and `request()` add argument 'cv' allowing optional signalling of a condition variable. The separate functions `recv_aio_signal()` and `request_signal()` are deprecated.
* `strcat()` is deprecated as considered non-core - it is recommended to replace usage with `sprintf()`.
* `status_code()` now returns the status code combined with the explanation as a character string.
* Performance enhancements for `unresolved()`, `call_aio()` and `call_aio_()`.

Expand Down
38 changes: 21 additions & 17 deletions R/context.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,36 @@ reply <- function(context,
#' @inheritSection recv_aio Signalling
#'
#' @examples
#' \dontrun{
#'
#' # works if req and rep are running in parallel in different processes
#'
#' # req <- socket("req", listen = "tcp://127.0.0.1:6546")
#' # rep <- socket("rep", dial = "tcp://127.0.0.1:6546")
#' req <- socket("req", listen = "tcp://127.0.0.1:6546")
#' rep <- socket("rep", dial = "tcp://127.0.0.1:6546")
#'
#' # reply(.context(rep), execute = function(x) x + 1, timeout = 50)
#' # aio <- request(.context(req), data = 2022)
#' # aio$data
#' reply(.context(rep), execute = function(x) x + 1, timeout = 50)
#' aio <- request(.context(req), data = 2022)
#' aio$data
#'
#' # close(req)
#' # close(rep)
#' close(req)
#' close(rep)
#'
#' # Signalling a condition variable
#'
#' # req <- socket("req", listen = "tcp://127.0.0.1:6546")
#' # ctxq <- context(req)
#' # cv <- cv()
#' # aio <- request_signal(ctxq, data = 2022, cv = cv)
#' # until(cv, 10L)
#' # close(req)
#' req <- socket("req", listen = "tcp://127.0.0.1:6546")
#' ctxq <- context(req)
#' cv <- cv()
#' aio <- request_signal(ctxq, data = 2022, cv = cv)
#' until(cv, 10L)
#' close(req)
#'
#' # The following should be run in another process
#' # rep <- socket("rep", dial = "tcp://127.0.0.1:6546")
#' # ctxp <- context(rep)
#' # reply(ctxp, execute = function(x) x + 1)
#' # close(rep)
#' rep <- socket("rep", dial = "tcp://127.0.0.1:6546")
#' ctxp <- context(rep)
#' reply(ctxp, execute = function(x) x + 1)
#' close(rep)
#'
#' }
#'
#' @export
#'
Expand Down
6 changes: 4 additions & 2 deletions R/sync.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ cv <- function() .Call(rnng_cv_alloc)
#' @param cv a \sQuote{conditionVariable} object.
#'
#' @examples
#' # wait(cv) # uncommenting will block until the cv is signalled
#' # wait_(cv) # block until the cv is signalled or interrupted
#' \dontrun{
#' wait(cv) # would block until the cv is signalled
#' wait_(cv) # would block until the cv is signalled or interrupted
#' }
#'
#' @rdname cv
#' @export
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ status_code <- function(x) .Call(rnng_status_code, x)
#' Concatenate Strings
#'
#' A fast implementation that combines two character values into a single string.
#' This function is deprecated and will be removed in a future version.
#'
#' @param a character value.
#' @param b character value.
Expand All @@ -277,6 +278,7 @@ status_code <- function(x) .Call(rnng_status_code, x)
#' @examples
#' strcat("hello ", "world!")
#'
#' @keywords internal
#' @export
#'
strcat <- function(a, b) .Call(rnng_strcat, a, b)
Expand Down
6 changes: 4 additions & 2 deletions man/cv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 21 additions & 17 deletions man/request.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/strcat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b91369

Please sign in to comment.