interprocess

Mutexes, Semaphores, and Message Queues for R

https://github.com/cmmr/interprocess

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Mutexes, Semaphores, and Message Queues for R

Basic Info
Statistics
  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Created about 1 year ago · Last pushed 11 months ago
Metadata Files
Readme Changelog License

README.md

interprocess interprocess logo

cran conda covr <!-- badges: end --> <!-- downloads dev -->

The goal of interprocess is to synchronize concurrent R processes.

Allows R to access low-level operating system mechanisms for performing atomic operations on shared data structures. Mutexes provide shared and exclusive locks. Semaphores act as counters. Message queues move text strings from one process to another. All these interprocess communication (IPC) tools can optionally block with or without a timeout.

Works cross-platform, including Windows, MacOS, and Linux, and can be used to synchronize a mixture of R sessions and other types of processes.

Implemented using the Boost C++ library.

Installation

``` r

Install the latest stable version from CRAN:

install.packages("interprocess")

Or the development version from GitHub:

install.packages("pak") pak::pak("cmmr/interprocess") ```

Usage

Mutexes, semaphores, and message queues are managed by the operating system. Any process that knows the resource's name can access it. Therefore, sharing the resource name (a short text string) amongst cooperating processes enables communication and synchronization.

These names can be any alphanumeric string that starts with a letter and is no longer than 250 characters. The mutex(), semaphore(), and msg_queue() functions will default to generating a unique identifier, or you can provide a custom or pre-existing one with the name parameter. If the resource is associated with a specific file or directory, the file parameter can be used to derive a name from normalizing and hashing that path.

Setting cleanup = TRUE will automatically remove the resource when the R session exits. Otherwise, the resource will persist until $remove() is called or the operating system is restarted.

Mutexes

An exclusive advisory lock is acquired by default. For a shared lock, use shared = TRUE. Set file = <path> to use a filepath hash for the name.

``` r tmp <- tempfile() mut <- interprocess::mutex(file = tmp)

mut$name

> [1] "oThd9KRpHb0"

with(mut, writeLines('Important Data', tmp))

with(mut, shared = TRUE, readLines(tmp))

> [1] "Important Data"

mut$remove() unlink(tmp) ```

Semaphores

The semaphore's value can be incremented with $post() and decremented with $wait(). The initial value can also be set in the constructor.

``` r sem <- interprocess::semaphore('mySemaphore', value = 1)

sem$name

> [1] "mySemaphore"

sem$post()

sem$wait(timeout_ms = 0)

> [1] TRUE

sem$wait(timeout_ms = 0)

> [1] TRUE

sem$wait(timeout_ms = 0)

> [1] FALSE

sem$remove() ```

Message Queues

The constructor's max_count and max_nchar parameters determine how much memory is allocated for the message queue.

``` r mq <- interprocess::msgqueue(maxcount = 2, max_nchar = 5)

mq$name

> [1] "Ae2udeRLWcb"

mq$send('Hello') mq$send('Hi', priority = 1)

mq$receive(timeout_ms = 0)

> [1] "Hi"

mq$receive(timeout_ms = 0)

> [1] "Hello"

mq$receive(timeout_ms = 0)

> [1] NULL

mq$remove() ```

Owner

  • Name: Alkek Center for Metagenomics and Microbiome Research
  • Login: cmmr
  • Kind: organization
  • Location: Baylor College of Medicine, Houston TX

CMMR researchers develop molecular and informatic tools to advance clinical microbiome research.

GitHub Events

Total
  • Create event: 5
  • Release event: 3
  • Issues event: 7
  • Watch event: 3
  • Push event: 54
Last Year
  • Create event: 5
  • Release event: 3
  • Issues event: 7
  • Watch event: 3
  • Push event: 54

Packages

  • Total packages: 1
  • Total downloads:
    • cran 534 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: interprocess

Mutexes, Semaphores, and Message Queues

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 534 Last month
Rankings
Dependent packages count: 26.6%
Dependent repos count: 32.8%
Average: 48.7%
Downloads: 86.7%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.5.0 composite
  • actions/checkout v4 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v4 composite
  • actions/upload-artifact v4 composite
  • codecov/codecov-action v4 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • Rcpp * imports
  • callr * suggests
  • rmarkdown * suggests
  • testthat * suggests