diff options
Diffstat (limited to 'externals/grill/vasp/source/buflib.cpp')
-rw-r--r-- | externals/grill/vasp/source/buflib.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/externals/grill/vasp/source/buflib.cpp b/externals/grill/vasp/source/buflib.cpp index 78866a8e..938a1969 100644 --- a/externals/grill/vasp/source/buflib.cpp +++ b/externals/grill/vasp/source/buflib.cpp @@ -24,23 +24,23 @@ WARRANTIES, see the file, "license.txt," in this distribution. class FreeEntry { public: - FreeEntry(t_symbol *s): sym(s),nxt(NULL) {} + FreeEntry(const t_symbol *s): sym(s),nxt(NULL) {} - t_symbol *sym; + const t_symbol *sym; FreeEntry *nxt; }; class BufEntry { public: - BufEntry(t_symbol *s,I fr,BL zero = true); + BufEntry(const t_symbol *s,I fr,BL zero = true); ~BufEntry(); V IncRef(); V DecRef(); // UL magic; - t_symbol *sym; + const t_symbol *sym; I refcnt,tick; BufEntry *nxt; @@ -57,12 +57,12 @@ static I libcnt = 0,libtick = 0; static flext::ThrMutex libmtx; #endif -static V FreeLibSym(t_symbol *s); +static V FreeLibSym(const t_symbol *s); -BufEntry::BufEntry(t_symbol *s,I fr,BL zero): +BufEntry::BufEntry(const t_symbol *s,I fr,BL zero): sym(s), //magic(LIBMAGIC), alloc(fr),len(fr),data(new S[fr]), refcnt(0),nxt(NULL) @@ -97,7 +97,7 @@ VBuffer *BufLib::Get(const VSymbol &s,I chn,I len,I offs) return new SysBuf(s,chn,len,offs); } -V BufLib::IncRef(t_symbol *s) +V BufLib::IncRef(const t_symbol *s) { if(s) { BufEntry *e = FindInLib(s); @@ -105,7 +105,7 @@ V BufLib::IncRef(t_symbol *s) } } -V BufLib::DecRef(t_symbol *s) +V BufLib::DecRef(const t_symbol *s) { if(s) { BufEntry *e = FindInLib(s); @@ -149,11 +149,11 @@ static V Collect() #ifdef FLEXT_THREADS static bool libthractive = false; -static pthread_t libthrid; +//static flext::thrid_t libthrid; static bool libthrexit = false; // currently not used static flext::ThrCond *libthrcond = NULL; -static V *LibThr(V *) +static V LibThr(flext::thr_params *) { flext::RelPriority(-2); @@ -162,7 +162,6 @@ static V *LibThr(V *) // TODO - should process return value of TimedWait Collect(); } - return NULL; } #endif @@ -180,14 +179,14 @@ static V LibTick(V *) } -static t_symbol *GetLibSym() +static const t_symbol *GetLibSym() { if(freehead) { // reuse from free-list FreeEntry *r = freehead; freehead = r->nxt; if(!freehead) freetail = NULL; - t_symbol *s = r->sym; + const t_symbol *s = r->sym; delete r; return s; } @@ -205,7 +204,7 @@ static t_symbol *GetLibSym() clock_delay(libclk,LIBTICK); } -static V FreeLibSym(t_symbol *sym) +static V FreeLibSym(const t_symbol *sym) { FreeEntry *f = new FreeEntry(sym); if(!freehead) freehead = f; @@ -218,8 +217,8 @@ BufEntry *BufLib::NewImm(I fr,BL zero) { #ifdef FLEXT_THREADS if(!libthractive) { - int ret = pthread_create(&libthrid,NULL,LibThr,NULL); - if(ret) + bool ret = flext::LaunchThread(LibThr,NULL); + if(!ret) error("vasp - Could not launch helper thread"); else { libthrcond = new flext::ThrCond; @@ -232,11 +231,7 @@ BufEntry *BufLib::NewImm(I fr,BL zero) clock_delay(libclk,LIBTICK); } - t_symbol *s = NULL; -// do { - s = GetLibSym(); -// } while(s->s_thing); - + const t_symbol *s = GetLibSym(); BufEntry *entry = new BufEntry(s,fr,zero); #ifdef FLEXT_THREADS @@ -300,6 +295,3 @@ I ImmBuf::Frames() const { return entry->len; } V ImmBuf::Frames(I fr,BL keep) { entry = BufLib::Resize(entry,fr,keep); } S *ImmBuf::Data() { return entry->data; } - - - |