Commit e4dd4b43 authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@264 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 6f641207
......@@ -87,6 +87,7 @@ Version history:
- ThrMutex: added lock count functions Push() and Pop()
- eliminated potentiallly dangerous SetThing,GetThing and introduced DoBind,DoUnbind,GetBound instead
- fixed severe bug with the current threads list
- add path specification possibility for help symbols (in FLEXT_NEW*)
0.3.1:
- added some more functionality to the AtomList class
......
......@@ -380,9 +380,9 @@ return 0; \
#define FLEXT_HELPSTR_DSP(NAME) #NAME "~"
#ifdef PD
#define FLEXT_DEFHELP(THIS,NEW_CLASS,DSP) ((NEW_CLASS *)THIS)->DefineHelp(DSP?FLEXT_HELPSTR_DSP(NEW_CLASS):FLEXT_HELPSTR(NEW_CLASS))
#define FLEXT_DEFHELP(THIS,NAME,NEW_CLASS,DSP) ((NEW_CLASS *)THIS)->DefineHelp(DSP?FLEXT_HELPSTR_DSP(NEW_CLASS):FLEXT_HELPSTR(NEW_CLASS),flext::extract(NAME,-1))
#else
#define FLEXT_DEFHELP(THIS,NEW_CLASS,DSP)
#define FLEXT_DEFHELP(THIS,NAME,NEW_CLASS,DSP)
#endif
// ----------------------------------------------------
......@@ -405,7 +405,7 @@ flext_hdr* class_ ## NEW_CLASS () \
obj->data = new NEW_CLASS; \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -433,7 +433,7 @@ flext_hdr* class_ ## NEW_CLASS () \
obj->data = new NEW_CLASS; \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -458,7 +458,7 @@ flext_hdr* class_ ## NEW_CLASS (t_symbol *,int argc,t_atom *argv) \
obj->data = new NEW_CLASS(argc,argv); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -487,7 +487,7 @@ flext_hdr* class_ ## NEW_CLASS (t_symbol *,int argc,t_atom *argv) \
obj->data = new NEW_CLASS(argc,argv); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -512,7 +512,7 @@ flext_hdr* class_ ## NEW_CLASS (CALLBTP(TYPE1) arg1) \
obj->data = new NEW_CLASS((TYPE1)arg1); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -541,7 +541,7 @@ flext_hdr* class_ ## NEW_CLASS (const flext_obj::lib_arg &arg1) \
obj->data = new NEW_CLASS(ARGCAST(arg1,TYPE1)); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -566,7 +566,7 @@ flext_hdr* class_ ## NEW_CLASS (CALLBTP(TYPE1) arg1, CALLBTP(TYPE2) arg2) \
obj->data = new NEW_CLASS((TYPE1)arg1, (TYPE2)arg2); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -595,7 +595,7 @@ flext_hdr* class_ ## NEW_CLASS (const flext_obj::lib_arg &arg1,const flext_obj::
obj->data = new NEW_CLASS(ARGCAST(arg1,TYPE1),ARGCAST(arg2,TYPE2)); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -620,7 +620,7 @@ flext_hdr* class_ ## NEW_CLASS (CALLBTP(TYPE1) arg1,CALLBTP(TYPE2) arg2,CALLBTP(
obj->data = new NEW_CLASS((TYPE1)arg1,(TYPE2)arg2,(TYPE3)arg3); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -649,7 +649,7 @@ flext_hdr* class_ ## NEW_CLASS (const flext_obj::lib_arg &arg1,const flext_obj::
obj->data = new NEW_CLASS(ARGCAST(arg1,TYPE1),ARGCAST(arg2,TYPE2),ARGCAST(arg3,TYPE3)); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -673,7 +673,7 @@ flext_hdr* class_ ## NEW_CLASS (CALLBTP(TYPE1) arg1,CALLBTP(TYPE2) arg2,CALLBTP(
obj->data = new NEW_CLASS((TYPE1)arg1,(TYPE2)arg2,(TYPE3)arg3,(TYPE4)arg4); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
FLEXT_EXP(LIB) void FLEXT_STPF(NEW_CLASS,DSP)() \
......@@ -702,7 +702,7 @@ flext_hdr* class_ ## NEW_CLASS (const flext_obj::lib_arg &arg1,const flext_obj::
obj->data = new NEW_CLASS(ARGCAST(arg1,TYPE1),ARGCAST(arg2,TYPE2),ARGCAST(arg3,TYPE3),ARGCAST(arg4,TYPE4)); \
flext_obj::m_holder = NULL; \
if(!obj->data->InitOk()) { NEW_CLASS::callb_free(obj); obj = NULL; } \
else FLEXT_DEFHELP(obj->data,NEW_CLASS,DSP); \
else FLEXT_DEFHELP(obj->data,NAME,NEW_CLASS,DSP); \
return(obj); \
} \
void FLEXT_STPF(NEW_CLASS,DSP)() \
......
......@@ -170,7 +170,7 @@ public:
@{
*/
void DefineHelp(const char *ref);
void DefineHelp(const char *ref,const char *dir = NULL);
//! @}
......@@ -491,26 +491,13 @@ public:
;
#endif
#if 0
/*! \brief Set current thread to normal priority
\bug Not working under all platforms
*/
void NormalPriority();
/*! \brief Set current thread to background priority
\bug Not working under all platforms
*/
void LowerPriority();
/*! \brief Set current thread to idle priority
\bug Not working under all platforms
*/
void LowestPriority();
static int GetPriority();
#else
/*! \brief Increase/Decrease priority of the current thread
*/
static void ChangePriority(int dp);
#endif
static void ChangePriority(int dp,pthread_t thr = pthread_self());
/*! \brief Get current thread id
*/
static pthread_t GetThreadId() { return pthread_self(); }
/*! \brief Thread mutex
\sa pthreads documentation
......
......@@ -205,10 +205,18 @@ flext_base::~flext_base()
}
void flext_base::DefineHelp(const char *ref)
void flext_base::DefineHelp(const char *ref,const char *dir)
{
#ifdef PD
class_sethelpsymbol(thisClass(),gensym(const_cast<char *>(ref)));
char tmp[256];
if(dir) {
strcpy(tmp,dir);
strcat(tmp,"/");
strcat(tmp,ref);
}
else
strcpy(tmp,ref);
class_sethelpsymbol(thisClass(),gensym(const_cast<char *>(tmp)));
#else
#endif
}
......
......@@ -18,6 +18,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define ALIASDEL ','
#define ALIASSLASHES ":/\\"
#ifdef MAXMSP
#define ALIASSLASH ':'
#elif defined(NT)
......@@ -43,20 +44,30 @@ const char *flext::extract(const char *name,int ix)
const char *n = name;
const char *del = strchr(name,ALIASDEL);
if(del) {
char *t;
for(t = tmp; *n && n < del && !isspace(*n); ++t,++n) *t = *n;
*(t++) = ALIASSLASH;
if(ix < 0) {
char *t = tmp;
while(n < del && (isspace(*n) || strchr(ALIASSLASHES,*n))) ++n;
while(n < del && !isspace(*n)) {
char c = *(n++);
*(t++) = strchr(ALIASSLASHES,c)?ALIASSLASH:c;
}
while(*t == ALIASSLASH && t > tmp) --t;
*t = 0;
return tmp;
}
n = del+1;
}
for(int i = 0; n && *n; ++i) {
if(i == ix) {
char *t;
for(t = tmp; *n && !isspace(*n); ++t,++n) *t = *n;
char *t = tmp;
for(; *n && !isspace(*n); ++t,++n) *t = *n;
*t = 0;
// return *tmp?flext::strdup(tmp):NULL;
return *tmp?tmp:NULL;
}
else {
......
......@@ -110,78 +110,16 @@ void flext_base::YTick(flext_base *th) {
#endif
/*
void flext_base::NormalPriority()
{
#ifdef NT
HANDLE thr = GetCurrentThread();
SetThreadPriority(thr,THREAD_PRIORITY_NORMAL);
#else
int policy = 0;
sched_param parm;
parm.sched_priority = 0;
if(pthread_setschedparam(pthread_self(),policy,&parm)) {
post("%s - failed to change priority",thisName());
}
#endif
}
void flext_base::LowerPriority()
{
#ifdef NT
HANDLE thr = GetCurrentThread();
SetThreadPriority(thr,THREAD_PRIORITY_BELOW_NORMAL);
#else
int policy = 0;
sched_param parm;
parm.sched_priority = -1;
if(pthread_setschedparam(pthread_self(),policy,&parm)) {
post("%s - failed to change priority",thisName());
}
#endif
}
void flext_base::LowestPriority()
{
#ifdef NT
HANDLE thr = GetCurrentThread();
SetThreadPriority(thr,THREAD_PRIORITY_LOWEST);
#else
int policy = 0;
sched_param parm;
parm.sched_priority = -2;
if(pthread_setschedparam(pthread_self(),policy,&parm)) {
post("%s - failed to change priority",thisName());
}
#endif
}
int flext_base::GetPriority()
{
sched_param parm;
int policy;
if(pthread_getschedparam(pthread_self(),&policy,&parm)) {
post("flext - failed to get parms");
return -1;
}
else
return parm.sched_priority;
}
*/
void flext_base::ChangePriority(int dp)
void flext_base::ChangePriority(int dp,pthread_t id)
{
sched_param parm;
int policy;
if(pthread_getschedparam(pthread_self(),&policy,&parm)) {
if(pthread_getschedparam(id,&policy,&parm)) {
post("flext - failed to get parms");
}
else {
parm.sched_priority += dp;
if(pthread_setschedparam(pthread_self(),policy,&parm)) {
if(pthread_setschedparam(id,policy,&parm)) {
post("flext - failed to change priority");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment