R/utils.R

Defines functions foreachCleanup closeSockets greaterOrEqual

greaterOrEqual <- function(x,y) {
    precision <- sqrt(.Machine$double.eps)
    (x >= y) | (abs(x-y) <= precision)
}

closeSockets <- function() {
    allCon <- showConnections()
    socketCon <- as.integer(rownames(allCon)[allCon[, "class"] == "sockconn"])
    sapply(socketCon, function(ii) close.connection(getConnection(ii)) )
}

foreachCleanup <- function() {
    if (exists(".revoDoParCluster", where=doParallel:::.options)) {
        if(!is.null(doParallel:::.options$.revoDoParCluster))
            stopCluster(doParallel:::.options$.revoDoParCluster)
        remove(".revoDoParCluster", envir=doParallel:::.options)
    }
}
rafalab/bumphunter documentation built on March 20, 2024, 6:22 a.m.