useDynLib("BiocParallel", .registration = TRUE)

import(methods)

importFrom(stats, setNames, terms)

importFrom(utils, capture.output, find, head, relist,
           setTxtProgressBar, txtProgressBar)


### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 classes
###

exportClass(
    BiocParallelParam,
    MulticoreParam,
    SnowParam,
    DoparParam,
    SerialParam,
    BatchJobsParam,
    BatchtoolsParam
)

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export non-generic functions
###

export(
    MulticoreParam, SnowParam, DoparParam, SerialParam, BatchJobsParam,
    BatchtoolsParam,

    ## register
    register, registered, bpparam,

    ## accessor
    bpnworkers,

    ## error handlers
    bpresume, bplasterror, bptry,

    ## helpers
    bploop,                             # worker, manager loops
    multicoreWorkers, snowWorkers,
    batchtoolsWorkers, batchtoolsCluster, batchtoolsRegistryargs,
    batchtoolsTemplate,
    bpvalidate, bpok,
    bprunMPIslave,

    ## ipcmutex
    ipcid, ipcremove, ipclock, ipctrylock, ipcunlock, ipclocked,
    ipcyield, ipcvalue, ipcreset
)

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 generics and methods defined in BiocParallel
###

export(
    bplapply, bpvec, bpvectorize, bpmapply, bpaggregate, bpiterate,

    ## bp-controls
    bpworkers, "bpworkers<-", bpbackend, "bpbackend<-",
    bptasks, "bptasks<-", bpjobname, "bpjobname<-",
    bpstart, bpstop, bpisup,
    bpcatchErrors, "bpcatchErrors<-", bpstopOnError, "bpstopOnError<-",
    bpprogressbar, "bpprogressbar<-", bpRNGseed, "bpRNGseed<-",
    bptimeout, "bptimeout<-", bpexportglobals, "bpexportglobals<-",
    bplog, "bplog<-", bplogdir, "bplogdir<-",
    bpthreshold, "bpthreshold<-", bpresultdir, "bpresultdir<-",

    ## schedule
    bpschedule
)

### Same list as above.
exportMethods(
    bplapply, bpvec, bpvectorize, bpmapply, bpaggregate, bpiterate,

    ## bp-controls
    bpworkers, "bpworkers<-", bpbackend, "bpbackend<-",
    bptasks, "bptasks<-", bpjobname, "bpjobname<-",
    bpstart, bpstop, bpisup,
    bpcatchErrors, "bpcatchErrors<-", bpstopOnError, "bpstopOnError<-",
    bpprogressbar, "bpprogressbar<-", bpRNGseed, "bpRNGseed<-",
    bptimeout, "bptimeout<-", bplog, "bplog<-", bplogdir, "bplogdir<-",
    bpthreshold, "bpthreshold<-", bpresultdir, "bpresultdir<-",

    ## schedule
    bpschedule
)

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S4 methods for generics not defined in BiocParallel
###

exportMethods(
    show
)

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Export S3 methods
###

S3method(print, remote_error)
S3method(print, bplist_error)

S3method(bploop, MPInode)
S3method(bploop, SOCKnode)
S3method(bploop, SOCK0node)
S3method(bploop, lapply)
S3method(bploop, iterate)
