@@ -37,6 +37,7 @@ async = R6::R6Class(classname = 'async',
3737 private = list (
3838
3939 vars = list (status_file = NULL ,
40+ verbose = FALSE ,
4041 upper = 100 ,
4142 lower = 0 ,
4243 auto.finish = TRUE ,
@@ -49,7 +50,11 @@ async = R6::R6Class(classname = 'async',
4950 vm = scan(private $ vars $ status_file ,
5051 what = " character" ,
5152 sep = " \n " ,quiet = TRUE )
52- print(vm )
53+
54+ if (private $ vars $ verbose ){
55+ message(paste0(" get status: " ,vm ))
56+ }
57+
5358 vm = try(stringr :: str_split(vm ,' zzzz ' )[[1 ]])
5459
5560 if (! inherits(vm ,' try-error' )){
@@ -65,15 +70,22 @@ async = R6::R6Class(classname = 'async',
6570 vm = paste0(value ,' zzzz ' ,msg ,' zzzz ' ,detail )
6671 write(vm , private $ vars $ status_file )
6772
73+ if (private $ vars $ verbose ){
74+ message(paste0(" set status: " ,vm ))
75+ }
76+
6877 vm.out = stringr :: str_split(vm ,' zzzz ' )[[1 ]]
6978 names(vm.out ) = c(' value' ,' message' ,' detail' )
79+
80+
81+
7082 private $ vars $ vm = vm.out
7183
7284
7385 },
7486
7587 interrupted = function (){
76- private $ get_status()[1 ] == " 7777"
88+ isTRUE( private $ get_status()[1 ] == " 7777" )
7789 },
7890
7991
@@ -85,7 +97,7 @@ async = R6::R6Class(classname = 'async',
8597
8698 }
8799
88- if (private $ get_status()[1 ] == as.character(private $ vars $ upper )
100+ if ( isTRUE( private $ get_status()[1 ] == as.character(private $ vars $ upper ) )
89101 && private $ vars $ auto.finish ) {
90102 # unlink(private$vars$status_file)
91103 stop(" Process finished" )
@@ -163,13 +175,16 @@ async = R6::R6Class(classname = 'async',
163175 # 'be interrupted when the progress is equal to the upper value.
164176 # ' @param reactive If its true generate a reactive expression
165177 # ' is a expression whose result will change over time.
178+ # ' @param verbose logical.If its TRUE provides much more
179+ # ' information about the flow of information between the R processes.
166180 # ' @param msg A single-element character vector;
167181 # ' the initial message to be pass between processes.
168182 # ' @param detail A single-element character vector;
169183 # ' the initial detail message to be pass between processes.
170184 initialize = function (lower , upper ,
171185 auto.finish = TRUE ,
172186 reactive = TRUE ,
187+ verbose = FALSE ,
173188 msg ,
174189 detail ){
175190
@@ -192,6 +207,7 @@ async = R6::R6Class(classname = 'async',
192207 checkmate :: expect_numeric(c(lower ,upper ),lower = 0 ,upper = 1000 )
193208 checkmate :: expect_logical(auto.finish ,max.len = 1 )
194209 checkmate :: expect_logical(reactive ,max.len = 1 )
210+ checkmate :: expect_logical(verbose ,max.len = 1 )
195211 checkmate :: expect_character(msg ,max.len = 1 )
196212 checkmate :: expect_character(detail ,max.len = 1 )
197213
@@ -211,6 +227,7 @@ async = R6::R6Class(classname = 'async',
211227 private $ .reactive = reactive
212228 private $ rx_trigger = reactiveTrigger()
213229
230+ private $ vars $ verbose = verbose
214231 private $ vars $ lower = lower
215232 private $ vars $ upper = upper
216233 private $ vars $ auto.finish = auto.finish
@@ -225,7 +242,10 @@ async = R6::R6Class(classname = 'async',
225242 # ' the interrupt detail message to be pass between processes.
226243 interrupt = function (msg = " process interrupted" , detail = " " ){
227244
228- args = list (value = 7777 , msg = msg , detail = ' ' )
245+ checkmate :: expect_character(msg ,max.len = 1 )
246+ checkmate :: expect_character(detail ,max.len = 1 )
247+
248+ args = list (value = 7777 , msg = msg , detail = detail )
229249 do.call(private $ set_status , args = args )
230250
231251 if (isTRUE(private $ .reactive )){
0 commit comments