From 75f2d0b6822500e91e9a0c3539270d9639555590 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Tue, 12 May 2020 08:38:35 +0200
Subject: [PATCH] api: Add new phase -- concurrency

* R/api.R(concurrency): New function.

* R/resources.R(NO_WORKERS): New parameter.
---
 R/api.R       | 8 ++++++++
 R/resources.R | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/R/api.R b/R/api.R
index ae7cdce..db9e935 100644
--- a/R/api.R
+++ b/R/api.R
@@ -187,6 +187,14 @@ vrfy_conf <- function(conf) {
     return(conf)
 }
 
+## @export
+concurrency <- function(m) {
+    m$conf$workers <- if (!is.null(m$conf$workers)) m$conf$workers else NO_WORKERS
+    
+    future::plan("multiprocess",workers=m$conf$workers)
+    message("workers: ",m$conf$workers)
+    m
+}
 
 
 
diff --git a/R/resources.R b/R/resources.R
index a5ca4b5..2041a75 100644
--- a/R/resources.R
+++ b/R/resources.R
@@ -132,3 +132,7 @@ EMPTY_MZML <- dtable(Files=character(0),
 
 
 FN_DATA_TAB <- "data-files.csv"
+
+
+## Default number of concurrent workers
+NO_WORKERS <- 2
-- 
GitLab