OpendTect-6_4  6.4
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
MemSetter< T > Class Template Reference

Sets large amounts of values to a constant using multiple threads. More...

Inheritance diagram for MemSetter< T >:
[legend]

Public Types

typedef T(* ValueFunc) ()
 
- Public Types inherited from Task
enum  Control { Run, Pause, Stop }
 

Public Member Functions

 MemSetter ()
 
 MemSetter (T *, T val, int64_t sz)
 
 MemSetter (ValueSeries< T > &, T val, int64_t sz)
 
void setValueFunc (ValueFunc valfunc)
 
void setValue (const T &val)
 
void setTarget (T *ptr)
 
void setTarget (ValueSeries< T > &vs)
 
void setSize (int64_t sz)
 
uiString uiMessage () const
 will be message() again in 7.x More...
 
uiString uiNrDoneText () const
 will be nrDoneText() in 7.x More...
 
- Public Member Functions inherited from ParallelTask
virtual ~ParallelTask ()
 
bool execute ()
 
virtual bool executeParallel (bool parallel)
 
void setProgressMeter (ProgressMeter *)
 Must be called before execute() More...
 
int64_t nrDone () const
 May be -1, i.e. class does not report nrdone. More...
 
int64_t totalNr () const
 
- Public Member Functions inherited from Task
virtual ~Task ()
 
virtual void enableWorkControl (bool=true)
 Must be called before execute() More...
 
bool workControlEnabled () const
 
virtual void controlWork (Control)
 
virtual Control getState () const
 
- Public Member Functions inherited from NamedObject
 NamedObject (const char *nm=0)
 
 NamedObject (const NamedObject *linkedto)
 
 NamedObject (const NamedObject &)
 
virtual ~NamedObject ()
 
void setLinkedTo (NamedObject *)
 
bool operator== (const NamedObject &oth) const
 
virtual const OD::Stringname () const
 
virtual const OD::StringannotName () const
 
virtual void setName (const char *)
 
void setCleanName (const char *)
 cleans string first More...
 
void deleteNotify (const CallBack &)
 
- Public Member Functions inherited from CallBacker
 CallBacker ()
 
 CallBacker (const CallBacker &)
 
virtual ~CallBacker ()
 
bool attachCB (NotifierAccess &, const CallBack &, bool onlyifnew=false)
 
bool attachCB (NotifierAccess *notif, const CallBack &cb, bool onlyifnew=false)
 
void detachCB (NotifierAccess &, const CallBack &)
 
void detachCB (NotifierAccess *notif, const CallBack &cb)
 
bool isNotifierAttached (NotifierAccess *) const
 Only for debugging purposes, don't use. More...
 

Protected Member Functions

int64_t nrIterations () const
 
int minThreadSize () const
 
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
template<>
bool setPtr (int64_t start, int64_t size)
 
- Protected Member Functions inherited from ParallelTask
virtual int maxNrThreads () const
 
virtual bool stopAllOnFailure () const
 
 ParallelTask (const char *nm=0)
 
 ParallelTask (const ParallelTask &)
 
int64_t calculateThreadSize (int64_t totalnr, int nrthreads, int thread) const
 
void addToNrDone (int64_t increment)
 
void quickAddToNrDone (int64_t loopidx)
 
void resetNrDone ()
 
- Protected Member Functions inherited from Task
 Task (const char *nm=0)
 
virtual bool shouldContinue ()
 
- Protected Member Functions inherited from CallBacker
void detachAllNotifiers ()
 Call from the destructor of your inherited object. More...
 

Protected Attributes

ValueSeries< T > * vs_
 
T * ptr_
 
int64_t sz_
 
val_
 
ValueFunc valfunc_
 
- Protected Attributes inherited from Task
Control control_
 
Threads::ConditionVarworkcontrolcondvar_
 
- Protected Attributes inherited from NamedObject
BufferStringname_
 
NamedObjectlinkedto_
 
CallBackSetdelnotify_
 

Private Member Functions

bool doPrepare (int)
 
bool doWork (int64_t, int64_t, int)
 

Static Private Member Functions

static uiString tr (const char *text, const char *disambiguation=0, int pluralnr=-1)
 
static uiString legacyTr (const char *text, const char *disambiguation=0, int pluralnr=-1)
 

Additional Inherited Members

- Static Public Member Functions inherited from ParallelTask
static uiString sPosFinished ()
 
static uiString sTrcFinished ()
 
- Static Public Member Functions inherited from Task
static uiString stdNrDoneText ()
 
static uiString uiStdNrDoneText ()
 

Detailed Description

template<class T>
class MemSetter< T >

Sets large amounts of values to a constant using multiple threads.

For simple initializations, use OD::memValueSet.

Member Typedef Documentation

template<class T>
typedef T(* MemSetter< T >::ValueFunc) ()

Constructor & Destructor Documentation

template<class T >
MemSetter< T >::MemSetter ( )
inline
template<class T >
MemSetter< T >::MemSetter ( T *  ptr,
val,
int64_t  sz 
)
inline
template<class T >
MemSetter< T >::MemSetter ( ValueSeries< T > &  vs,
val,
int64_t  sz 
)
inline

Member Function Documentation

template<class T >
bool MemSetter< T >::doPrepare ( int  nrthreads)
inlineprivatevirtual

Called once, before any doWork is called.

Reimplemented from ParallelTask.

template<class T >
bool MemSetter< T >::doWork ( int64_t  start,
int64_t  stop,
int  threadidx 
)
inlineprivatevirtual

The functions that does the job. The function will be called with all intervals from 0 to ParallelTask::nrIterations()-1. The function must be designed to be able to run in parallel.

Parameters
threadidgives an identifier (between 0 and nr of threads -1) that is unique to each call to doWork.

Implements ParallelTask.

template<class T>
static uiString MemSetter< T >::legacyTr ( const char *  text,
const char *  disambiguation = 0,
int  pluralnr = -1 
)
inlinestaticprivate
template<class T>
int MemSetter< T >::minThreadSize ( ) const
inlineprotectedvirtual
Returns
the minimum number of computations that effectively can be run in a separate thread. A small number will give a large overhead for when each step is quick and nrIterations is not big.

Reimplemented from ParallelTask.

template<class T>
int64_t MemSetter< T >::nrIterations ( ) const
inlineprotectedvirtual
Returns
the number of times the process should be run.

Implements ParallelTask.

template<class T >
bool MemSetter< T >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< char >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< unsigned char >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< bool >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< float >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< double >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< int >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< unsigned int >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< short >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< unsigned short >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< int64_t >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<>
bool MemSetter< uint64_t >::setPtr ( int64_t  start,
int64_t  size 
)
inlineprotected
template<class T>
void MemSetter< T >::setSize ( int64_t  sz)
inline
template<class T>
void MemSetter< T >::setTarget ( T *  ptr)
inline
template<class T>
void MemSetter< T >::setTarget ( ValueSeries< T > &  vs)
inline
template<class T>
void MemSetter< T >::setValue ( const T &  val)
inline
template<class T>
void MemSetter< T >::setValueFunc ( ValueFunc  valfunc)
inline
template<class T>
static uiString MemSetter< T >::tr ( const char *  text,
const char *  disambiguation = 0,
int  pluralnr = -1 
)
inlinestaticprivate
template<class T>
uiString MemSetter< T >::uiMessage ( ) const
inlinevirtual

will be message() again in 7.x

Note
totalNr is only used for displaying progress.

Reimplemented from Task.

template<class T>
uiString MemSetter< T >::uiNrDoneText ( ) const
inlinevirtual

will be nrDoneText() in 7.x

Reimplemented from Task.

Member Data Documentation

template<class T>
T* MemSetter< T >::ptr_
protected
template<class T>
int64_t MemSetter< T >::sz_
protected
template<class T>
T MemSetter< T >::val_
protected
template<class T>
ValueFunc MemSetter< T >::valfunc_
protected
template<class T>
ValueSeries<T>* MemSetter< T >::vs_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019