FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number) : TankNumber(tank_number) { string token, strFuelName; Element* element; Element* element_Grain; FGPropertyManager *PropertyManager = exec->GetPropertyManager(); Area = 1.0; Density = 6.6; InitialTemperature = Temperature = -9999.0; Ixx = Iyy = Izz = 0.0; InertiaFactor = 1.0; Radius = Contents = Standpipe = Length = InnerRadius = 0.0; ExternalFlow = 0.0; InitialStandpipe = 0.0; Capacity = 0.00001; Priority = InitialPriority = 1; vXYZ.InitMatrix(); vXYZ_drain.InitMatrix(); ixx_unit = iyy_unit = izz_unit = 1.0; grainType = gtUNKNOWN; // This is the default type = el->GetAttributeValue("type"); if (type == "FUEL") Type = ttFUEL; else if (type == "OXIDIZER") Type = ttOXIDIZER; else Type = ttUNKNOWN; element = el->FindElement("location"); if (element) vXYZ = element->FindElementTripletConvertTo("IN"); else cerr << "No location found for this tank." << endl; vXYZ_drain = vXYZ; // Set initial drain location to initial tank CG element = el->FindElement("drain_location"); if (element) { vXYZ_drain = element->FindElementTripletConvertTo("IN"); } if (el->FindElement("radius")) Radius = el->FindElementValueAsNumberConvertTo("radius", "IN"); if (el->FindElement("inertia_factor")) InertiaFactor = el->FindElementValueAsNumber("inertia_factor"); if (el->FindElement("capacity")) Capacity = el->FindElementValueAsNumberConvertTo("capacity", "LBS"); if (el->FindElement("contents")) InitialContents = Contents = el->FindElementValueAsNumberConvertTo("contents", "LBS"); if (el->FindElement("temperature")) InitialTemperature = Temperature = el->FindElementValueAsNumber("temperature"); if (el->FindElement("standpipe")) InitialStandpipe = Standpipe = el->FindElementValueAsNumberConvertTo("standpipe", "LBS"); if (el->FindElement("priority")) InitialPriority = Priority = (int)el->FindElementValueAsNumber("priority"); if (el->FindElement("density")) Density = el->FindElementValueAsNumberConvertTo("density", "LBS/GAL"); if (el->FindElement("type")) strFuelName = el->FindElementValue("type"); SetPriority( InitialPriority ); // this will also set the Selected flag if (Capacity == 0) { cerr << "Tank capacity must not be zero. Reset to 0.00001 lbs!" << endl; Capacity = 0.00001; Contents = 0.0; } if (Contents > Capacity) { cerr << "Tank content (" << Contents << " lbs) is greater than tank capacity (" << Capacity << " lbs) for tank " << tank_number << "! Did you accidentally swap contents and capacity?" << endl; throw("tank definition error"); } PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0 // Check whether this is a solid propellant "tank". Initialize it if true. element_Grain = el->FindElement("grain_config"); if (element_Grain) { strGType = element_Grain->GetAttributeValue("type"); if (strGType == "CYLINDRICAL") grainType = gtCYLINDRICAL; else if (strGType == "ENDBURNING") grainType = gtENDBURNING; else if (strGType == "FUNCTION") { grainType = gtFUNCTION; if (element_Grain->FindElement("ixx") != 0) { Element* element_ixx = element_Grain->FindElement("ixx"); if (element_ixx->GetAttributeValue("unit") == "KG*M2") ixx_unit = 1.0/1.35594; if (element_ixx->FindElement("function") != 0) { function_ixx = new FGFunction(PropertyManager, element_ixx->FindElement("function")); } } else { throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an ixx must be specified when the FUNCTION grain type is specified."); } if (element_Grain->FindElement("iyy")) { Element* element_iyy = element_Grain->FindElement("iyy"); if (element_iyy->GetAttributeValue("unit") == "KG*M2") iyy_unit = 1.0/1.35594; if (element_iyy->FindElement("function") != 0) { function_iyy = new FGFunction(PropertyManager, element_iyy->FindElement("function")); } } else { throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an iyy must be specified when the FUNCTION grain type is specified."); } if (element_Grain->FindElement("izz")) { Element* element_izz = element_Grain->FindElement("izz"); if (element_izz->GetAttributeValue("unit") == "KG*M2") izz_unit = 1.0/1.35594; if (element_izz->FindElement("function") != 0) { function_izz = new FGFunction(PropertyManager, element_izz->FindElement("function")); } } else { throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an izz must be specified when the FUNCTION grain type is specified."); } } else cerr << "Unknown propellant grain type specified" << endl; if (element_Grain->FindElement("length")) Length = element_Grain->FindElementValueAsNumberConvertTo("length", "IN"); if (element_Grain->FindElement("bore_diameter")) InnerRadius = element_Grain->FindElementValueAsNumberConvertTo("bore_diameter", "IN")/2.0; // Initialize solid propellant values for debug and runtime use. switch (grainType) { case gtCYLINDRICAL: if (Radius <= InnerRadius) { std::stringstream error; error << "The bore diameter should be smaller than the total grain diameter!" << endl; throw std::runtime_error(error.str()); } Volume = M_PI * Length * (Radius*Radius - InnerRadius*InnerRadius); // cubic inches break; case gtENDBURNING: Volume = M_PI * Length * Radius * Radius; // cubic inches break; case gtFUNCTION: Volume = 1; // Volume is irrelevant for the FUNCTION type, but it can't be zero! break; case gtUNKNOWN: std::stringstream error; error << "Unknown grain type found in this rocket engine definition." << endl; throw std::runtime_error(error.str()); } Density = (Contents*lbtoslug)/Volume; // slugs/in^3 } CalculateInertias(); if (Temperature != -9999.0) InitialTemperature = Temperature = FahrenheitToCelsius(Temperature); Area = 40.0 * pow(Capacity/1975, 0.666666667); // A named fuel type will override a previous density value if (!strFuelName.empty()) Density = ProcessFuelName(strFuelName); bind(PropertyManager); Debug(0); }
//センサからデータを取得 void* SensorDataThread(void *param) { sigset_t ss; siginfo_t sig; struct timespec timeOut; int sigNo; int oldOutputMode = MODE_CLOCK; unsigned int i; const unsigned int dpSleepTime = 100000; //log用 time_t t; struct tm *ts; char dateBuf[20]; //シグナルのタイムアウト timeOut.tv_sec = g_dataInterval; timeOut.tv_nsec = 0; if( SetSignalBlock(&ss) == -1 ) pthread_exit(NULL); //スレッドを高優先に SetPriority(HIGH_PRIO); do{ if( sigNo == THREAD_MSG_EXIT ) { MySysLog(LOG_DEBUG, "Data Thread exit signal\n"); break; } //センサー間隔が1分以上はセンサー実行時アニメーションモードにする if( g_dataInterval >= 60 ) { oldOutputMode = g_outputMode; g_outputMode = MODE_ANI_0; } //DPの桁 //sensorが何かで止まるので個別にログを取ってどこで止まるか確認 //log用の時間 t = time(NULL); ts = localtime(&t); //strftime(dateBuf, sizeof(dateBuf), "%F %T", ts); strftime(dateBuf, sizeof(dateBuf), "%T", ts); SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%s\t", dateBuf); //時刻 i = 0; //Lps331をone shotモードでたたき起こす //SetDP(i++, DP_ON); usleep(dpSleepTime); WakeUpLps331(); //外気温 //SetDP(i++, DP_ON); usleep(dpSleepTime); g_temp = GetTemp(); SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.1f\t", g_temp); //外気温 //気圧 //SetDP(i++, DP_ON); usleep(dpSleepTime); g_press = GetPress(); SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.1f\t", g_press); //大気圧 //照度 //SetDP(i++, DP_ON); usleep(dpSleepTime); //g_lux = GetLuxOhm(100e+3); //100kohm g_lux = GetLux(); Set7segLightControl(g_lux); if( g_lux < 1 ) SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.4f\t", g_lux); //照度 else SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.1f\t", g_lux); //照度 //湿度 g_hum = GetHumidity(); SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.1f\t", g_hum); //湿度 //CPU温度 g_coreTemp = GetCoreTemp(); SensorLogPrintf(SENSOR_LOG_LEVEL_0, "%.1f\n", g_coreTemp); //CPU温度 usleep(dpSleepTime); //for( i=0; i<SEG_COUNT; i++) // SetDP(i, DP_OFF); //g_dispData[i] &= ~(SEG_DP); ////正常にデータ取得後データの保存 //SensorLog(); //モードを元に戻す if( g_dataInterval >= 60 ) g_outputMode = oldOutputMode; //残り時間用に現在の時間の取得 clock_gettime(CLOCK_MONOTONIC, &g_waitLog); sigNo = sigtimedwait( &ss, &sig, &timeOut); //何らかの形でシグナルが来なかった時の保険 if( g_threadStatus == 0 ) break; }while( 1 ); SetPriority(NOMAL_PRIO); g_threadStatus = 0; pthread_exit(NULL); }
LoadResourceAsync(IResourceCache* cache, CMResource& res, OnResourceLoadedCallback cb) : m_pCache(cache), m_res(res), m_cb(cb) { SetPriority(THREAD_PRIORITY_HIGHEST); }
void ConstructNullFunctionData( PADAPTER padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, u8 bQoS, u8 AC, u8 bEosp, u8 bForcePowerSave) { struct rtw_ieee80211_hdr *pwlanhdr; u16 *fctrl; u32 pktlen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); //DBG_871X("%s:%d\n", __FUNCTION__, bForcePowerSave); pwlanhdr = (struct rtw_ieee80211_hdr*)pframe; fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; if (bForcePowerSave) { SetPwrMgt(fctrl); } switch(cur_network->network.InfrastructureMode) { case Ndis802_11Infrastructure: SetToDs(fctrl); _rtw_memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); _rtw_memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); _rtw_memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); break; case Ndis802_11APMode: SetFrDs(fctrl); _rtw_memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); _rtw_memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); _rtw_memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); break; case Ndis802_11IBSS: default: _rtw_memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); _rtw_memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); _rtw_memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); break; } SetSeqNum(pwlanhdr, 0); if (bQoS == _TRUE) { struct rtw_ieee80211_hdr_3addr_qos *pwlanqoshdr; SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); pwlanqoshdr = (struct rtw_ieee80211_hdr_3addr_qos*)pframe; SetPriority(&pwlanqoshdr->qc, AC); SetEOSP(&pwlanqoshdr->qc, bEosp); pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); } else { SetFrameSubType(pframe, WIFI_DATA_NULL); pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); } *pLength = pktlen; }
void cXVDRServer::Action(void) { fd_set fds; struct timeval tv; cTimeMs channelReloadTimer; cTimeMs channelCacheTimer; cTimeMs recordingReloadTimer; bool channelReloadTrigger = false; bool recordingReloadTrigger = false; uint64_t channelsHash = 0; SetPriority(19); // get initial state of the recordings int recState = -1; int recStateOld = -1; Recordings.StateChanged(recState); recStateOld = recState; while (Running()) { FD_ZERO(&fds); FD_SET(m_ServerFD, &fds); tv.tv_sec = 0; tv.tv_usec = 250*1000; int r = select(m_ServerFD + 1, &fds, NULL, NULL, &tv); if (r == -1) { ERRORLOG("failed during select"); continue; } if (r == 0) { // remove disconnected clients bool bChanged = false; for (ClientList::iterator i = m_clients.begin(); i != m_clients.end();) { if (!(*i)->Active()) { INFOLOG("Client with ID %u seems to be disconnected, removing from client list", (*i)->GetID()); delete (*i); i = m_clients.erase(i); bChanged = true; } else { i++; } } // store channel cache if(bChanged) { cChannelCache::SaveChannelCacheData(); } // trigger clients to reload the modified channel list if(m_clients.size() > 0) { uint64_t hash = XVDRChannels.CheckUpdates(); XVDRChannels.Lock(false); if(hash != channelsHash) { channelReloadTrigger = true; channelReloadTimer.Set(0); } if(channelReloadTrigger && channelReloadTimer.Elapsed() >= 10*1000) { INFOLOG("Checking for channel updates ..."); for (ClientList::iterator i = m_clients.begin(); i != m_clients.end(); i++) (*i)->ChannelsChanged(); channelReloadTrigger = false; INFOLOG("Done."); } XVDRChannels.Unlock(); channelsHash = hash; } // reset inactivity timeout as long as there are clients connected if(m_clients.size() > 0) { ShutdownHandler.SetUserInactiveTimeout(); } // store channel cache if(m_clients.size() > 0 && channelCacheTimer.Elapsed() >= 60*1000) { if(!bChanged) { cChannelCache::SaveChannelCacheData(); } channelCacheTimer.Set(0); } // check for recording changes Recordings.StateChanged(recState); if(recState != recStateOld) { recordingReloadTrigger = true; recordingReloadTimer.Set(2000); INFOLOG("Recordings state changed (%i)", recState); recStateOld = recState; } // update recordings if((recordingReloadTrigger && recordingReloadTimer.TimedOut()) || cRecordingsCache::GetInstance().Changed()) { // start gc if reload was triggered if(!cRecordingsCache::GetInstance().Changed()) { INFOLOG("Starting garbage collection in recordings cache"); cRecordingsCache::GetInstance().gc(); } // request clients to reload recordings if(!m_clients.empty()) { INFOLOG("Requesting clients to reload recordings list"); for (ClientList::iterator i = m_clients.begin(); i != m_clients.end(); i++) { (*i)->RecordingsChange(); } } recordingReloadTrigger = false; } // no connect request -> continue waiting continue; } int fd = accept(m_ServerFD, 0, 0); if (fd >= 0) { NewClientConnected(fd); } else { ERRORLOG("accept failed"); } } return; }
bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded) { int priority = GetPriority(sound); // Seeks a channel used which sound is stopped. for (auto& it : m_channels) { if (it.second->IsPlaying()) { continue; } if (it.second->GetSoundType() != sound) { continue; } it.second->SetPriority(priority); it.second->Reset(); channel = it.first; alreadyLoaded = it.second->IsLoaded(); return true; } // just add a new channel if we dont have any if (m_channels.size() == 0) { auto chn = MakeUnique<Channel>(); // check if we channel ready to play music, if not report error if (chn->IsReady()) { chn->SetPriority(priority); chn->Reset(); channel = 1; m_channels[channel] = std::move(chn); alreadyLoaded = false; return true; } GetLogger()->Error("Could not open channel to play sound!\n"); return false; } // Assigns new channel within limit if (m_channels.size() < m_channelsLimit) { auto it = m_channels.end(); it--; int i = (*it).first; while (++i) { if (m_channels.find(i) == m_channels.end()) { auto chn = MakeUnique<Channel>(); // check if channel is ready to play music, if not destroy it and seek free one if (chn->IsReady()) { chn->SetPriority(priority); chn->Reset(); m_channels[i] = std::move(chn); channel = i; alreadyLoaded = false; return true; } GetLogger()->Debug("Could not open additional channel to play sound!\n"); break; } } } int lowerOrEqual = -1; for (auto& it : m_channels) { if (it.second->GetPriority() < priority) { GetLogger()->Debug("Sound channel with lower priority will be reused.\n"); channel = it.first; it.second->Reset(); return true; } if (it.second->GetPriority() <= priority) lowerOrEqual = it.first; } if (lowerOrEqual != -1) { channel = lowerOrEqual; m_channels[channel]->Reset(); GetLogger()->Debug("Sound channel with lower or equal priority will be reused.\n"); return true; } GetLogger()->Debug("Could not find free buffer to use.\n"); return false; }
static sint make_wlanhdr(struct _adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; __le16 *fctrl = &pwlanhdr->frame_ctl; memset(hdr, 0, WLANHDR_OFFSET); SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* to_ds = 1, fr_ds = 0; */ SetToDs(fctrl); memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* to_ds = 0, fr_ds = 1; */ SetFrDs(fctrl); memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); } else { return _FAIL; } if (pattrib->encrypt) SetPrivacy(fctrl); if (pqospriv->qos_option) { qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); if (pattrib->priority) SetPriority(qc, pattrib->priority); SetAckpolicy(qc, pattrib->ack_policy); } /* TODO: fill HT Control Field */ /* Update Seq Num will be handled by f/w */ { struct sta_info *psta; sint bmcst = IS_MCAST(pattrib->ra); if (pattrib->psta) { psta = pattrib->psta; } else { if (bmcst) psta = r8712_get_bcmc_stainfo(padapter); else psta = r8712_get_stainfo(&padapter->stapriv, pattrib->ra); } if (psta) { psta->sta_xmitpriv.txseq_tid [pattrib->priority]++; psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; pattrib->seqnum = psta->sta_xmitpriv. txseq_tid[pattrib->priority]; SetSeqNum(hdr, pattrib->seqnum); } } } return _SUCCESS; }
void LANGUAGE_CODE_DESCRIPTOR::Separator(int _priority) { bSeparator = true; SetPriority(_priority); usage_counter = -1.; }
void CommandData::ProcessSwitch(char *Switch,wchar *SwitchW) { switch(etoupper(Switch[0])) { case 'I': if (strnicomp(&Switch[1],"LOG",3)==0) { strncpyz(LogName,Switch[4] ? Switch+4:DefLogName,ASIZE(LogName)); break; } if (stricomp(&Switch[1],"SND")==0) { Sound=true; break; } if (stricomp(&Switch[1],"ERR")==0) { MsgStream=MSG_STDERR; break; } if (strnicomp(&Switch[1],"EML",3)==0) { strncpyz(EmailTo,Switch[4] ? Switch+4:"@",ASIZE(EmailTo)); EmailTo[sizeof(EmailTo)-1]=0; break; } if (stricomp(&Switch[1],"NUL")==0) { MsgStream=MSG_NULL; break; } if (etoupper(Switch[1])=='D') { for (int I=2;Switch[I]!=0;I++) switch(etoupper(Switch[I])) { case 'Q': MsgStream=MSG_ERRONLY; break; case 'C': DisableCopyright=true; break; case 'D': DisableDone=true; break; case 'P': DisablePercentage=true; break; } break; } if (stricomp(&Switch[1],"OFF")==0) { Shutdown=true; break; } break; case 'T': switch(etoupper(Switch[1])) { case 'K': ArcTime=ARCTIME_KEEP; break; case 'L': ArcTime=ARCTIME_LATEST; break; case 'O': FileTimeBefore.SetAgeText(Switch+2); break; case 'N': FileTimeAfter.SetAgeText(Switch+2); break; case 'B': FileTimeBefore.SetIsoText(Switch+2); break; case 'A': FileTimeAfter.SetIsoText(Switch+2); break; case 'S': { EXTTIME_MODE Mode=EXTTIME_HIGH3; bool CommonMode=Switch[2]>='0' && Switch[2]<='4'; if (CommonMode) Mode=(EXTTIME_MODE)(Switch[2]-'0'); if (Switch[2]=='-') Mode=EXTTIME_NONE; if (CommonMode || Switch[2]=='-' || Switch[2]=='+' || Switch[2]==0) xmtime=xctime=xatime=Mode; else { if (Switch[3]>='0' && Switch[3]<='4') Mode=(EXTTIME_MODE)(Switch[3]-'0'); if (Switch[3]=='-') Mode=EXTTIME_NONE; switch(etoupper(Switch[2])) { case 'M': xmtime=Mode; break; case 'C': xctime=Mode; break; case 'A': xatime=Mode; break; case 'R': xarctime=Mode; break; } } } break; case '-': Test=false; break; case 0: Test=true; break; default: BadSwitch(Switch); break; } break; case 'A': switch(etoupper(Switch[1])) { case 'C': ClearArc=true; break; case 'D': AppendArcNameToPath=true; break; case 'G': if (Switch[2]=='-' && Switch[3]==0) GenerateArcName=0; else { GenerateArcName=true; strncpyz(GenerateMask,Switch+2,ASIZE(GenerateMask)); } break; case 'N': //reserved for archive name break; case 'O': AddArcOnly=true; break; case 'P': strcpy(ArcPath,Switch+2); if (SwitchW!=NULL && *SwitchW!=0) strcpyw(ArcPathW,SwitchW+2); break; case 'S': SyncFiles=true; break; default: BadSwitch(Switch); break; } break; case 'D': if (Switch[2]==0) switch(etoupper(Switch[1])) { case 'S': DisableSortSolid=true; break; case 'H': OpenShared=true; break; case 'F': DeleteFiles=true; break; } break; case 'O': switch(etoupper(Switch[1])) { case '+': Overwrite=OVERWRITE_ALL; break; case '-': Overwrite=OVERWRITE_NONE; break; case 0: Overwrite=OVERWRITE_FORCE_ASK; break; case 'R': Overwrite=OVERWRITE_AUTORENAME; break; case 'W': ProcessOwners=true; break; #ifdef SAVE_LINKS case 'L': SaveLinks=true; break; #endif #ifdef _WIN_32 case 'S': SaveStreams=true; break; case 'C': SetCompressedAttr=true; break; #endif default : BadSwitch(Switch); break; } break; case 'R': switch(etoupper(Switch[1])) { case 0: Recurse=RECURSE_ALWAYS; break; case '-': Recurse=0; break; case '0': Recurse=RECURSE_WILDCARDS; break; #ifndef _WIN_CE case 'I': { Priority=atoi(Switch+2); char *ChPtr=strchr(Switch+2,':'); if (ChPtr!=NULL) { SleepTime=atoi(ChPtr+1); InitSystemOptions(SleepTime); } SetPriority(Priority); } break; #endif } break; case 'Y': AllYes=true; break; case 'N': case 'X': if (Switch[1]!=0) { StringList *Args=etoupper(Switch[0])=='N' ? InclArgs:ExclArgs; if (Switch[1]=='@' && !IsWildcard(Switch)) { RAR_CHARSET Charset=FilelistCharset; #if defined(_WIN_32) && !defined(GUI) // for compatibility reasons we use OEM encoding // in Win32 console version by default if (Charset==RCH_DEFAULT) Charset=RCH_OEM; #endif ReadTextFile(Switch+2,Args,false,true,Charset,true,true,true); } else Args->AddString(Switch+1); } break; case 'E': switch(etoupper(Switch[1])) { case 'P': switch(Switch[2]) { case 0: ExclPath=EXCL_SKIPWHOLEPATH; break; case '1': ExclPath=EXCL_BASEPATH; break; case '2': ExclPath=EXCL_SAVEFULLPATH; break; case '3': ExclPath=EXCL_ABSPATH; break; } break; case 'D': ExclEmptyDir=true; break; case 'E': ProcessEA=false; break; case 'N': NoEndBlock=true; break; default: if (Switch[1]=='+') { InclFileAttr=GetExclAttr(&Switch[2]); InclAttrSet=true; } else ExclFileAttr=GetExclAttr(&Switch[1]); break; } break; case 'P': if (Switch[1]==0) { GetPassword(PASSWORD_GLOBAL,NULL,Password,sizeof(Password)); eprintf("\n"); } else strncpyz(Password,Switch+1,ASIZE(Password)); break; case 'H': if (etoupper(Switch[1])=='P') { EncryptHeaders=true; if (Switch[2]!=0) strncpyz(Password,Switch+2,ASIZE(Password)); else if (*Password==0) { GetPassword(PASSWORD_GLOBAL,NULL,Password,sizeof(Password)); eprintf("\n"); } } break; case 'Z': strncpyz(CommentFile,Switch[1]!=0 ? Switch+1:"stdin",ASIZE(CommentFile)); break; case 'M': switch(etoupper(Switch[1])) { case 'C': { char *Str=Switch+2; if (*Str=='-') for (int I=0;I<sizeof(FilterModes)/sizeof(FilterModes[0]);I++) FilterModes[I].State=FILTER_DISABLE; else while (*Str) { int Param1=0,Param2=0; FilterState State=FILTER_AUTO; FilterType Type=FILTER_NONE; if (isdigit(*Str)) { Param1=atoi(Str); while (isdigit(*Str)) Str++; } if (*Str==':' && isdigit(Str[1])) { Param2=atoi(++Str); while (isdigit(*Str)) Str++; } switch(etoupper(*(Str++))) { case 'T': Type=FILTER_PPM; break; case 'E': Type=FILTER_E8; break; case 'D': Type=FILTER_DELTA; break; case 'A': Type=FILTER_AUDIO; break; case 'C': Type=FILTER_RGB; break; case 'I': Type=FILTER_ITANIUM; break; case 'L': Type=FILTER_UPCASETOLOW; break; } if (*Str=='+' || *Str=='-') State=*(Str++)=='+' ? FILTER_FORCE:FILTER_DISABLE; FilterModes[Type].State=State; FilterModes[Type].Param1=Param1; FilterModes[Type].Param2=Param2; } } break; case 'M': break; case 'D': { if ((WinSize=atoi(&Switch[2]))==0) WinSize=0x10000<<(etoupper(Switch[2])-'A'); else WinSize*=1024; if (!CheckWinSize()) BadSwitch(Switch); } break; case 'S': { char *Names=Switch+2,DefNames[512]; if (*Names==0) { strcpy(DefNames,DefaultStoreList); Names=DefNames; } while (*Names!=0) { char *End=strchr(Names,';'); if (End!=NULL) *End=0; if (*Names=='.') Names++; char Mask[NM]; if (strpbrk(Names,"*?.")==NULL) sprintf(Mask,"*.%s",Names); else strcpy(Mask,Names); StoreArgs->AddString(Mask); if (End==NULL) break; Names=End+1; } } break; #ifdef PACK_SMP case 'T': Threads=atoi(Switch+2); if (Threads>MaxSearchThreads) BadSwitch(Switch); else { } break; #endif default: Method=Switch[1]-'0'; if (Method>5 || Method<0) BadSwitch(Switch); break; } break; case 'V': switch(etoupper(Switch[1])) { #ifdef _WIN_32 case 'D': EraseDisk=true; break; #endif case 'N': OldNumbering=true; break; case 'P': VolumePause=true; break; case 'E': if (etoupper(Switch[2])=='R') VersionControl=atoi(Switch+3)+1; break; case '-': VolSize=0; break; default: { Int64 NewVolSize=atoil(&Switch[1]); if (NewVolSize==0) NewVolSize=INT64ERR; else switch (Switch[strlen(Switch)-1]) { case 'f': case 'F': switch(int64to32(NewVolSize)) { case 360: NewVolSize=362496; break; case 720: NewVolSize=730112; break; case 1200: NewVolSize=1213952; break; case 1440: NewVolSize=1457664; break; case 2880: NewVolSize=2915328; break; } break; case 'k': NewVolSize*=1024; break; case 'm': NewVolSize*=1024*1024; break; case 'M': NewVolSize*=1000*1000; break; case 'g': NewVolSize*=1024*1024; NewVolSize*=1024; break; case 'G': NewVolSize*=1000*1000; NewVolSize*=1000; break; case 'b': case 'B': break; default: NewVolSize*=1000; break; } if (VolSize==0) VolSize=NewVolSize; else NextVolSizes.Push(NewVolSize); } break; } break; case 'F': if (Switch[1]==0) FreshFiles=true; else BadSwitch(Switch); break; case 'U': if (Switch[1]==0) UpdateFiles=true; else BadSwitch(Switch); break; case 'W': strncpyz(TempPath,&Switch[1],ASIZE(TempPath)); AddEndSlash(TempPath); break; case 'S': if (strnicomp(Switch,"SFX",3)==0) { const char *SFXName=Switch[3] ? Switch+3:DefSFXName; if (PointToName(SFXName)!=SFXName || FileExist(SFXName)) strcpy(SFXModule,SFXName); else GetConfigName(SFXName,SFXModule,true); } if (isdigit(Switch[1])) { Solid|=SOLID_COUNT; SolidCount=atoi(&Switch[1]); } else switch(etoupper(Switch[1])) { case 0: Solid|=SOLID_NORMAL; break; case '-': Solid=SOLID_NONE; break; case 'E': Solid|=SOLID_FILEEXT; break; case 'V': Solid|=Switch[2]=='-' ? SOLID_VOLUME_DEPENDENT:SOLID_VOLUME_INDEPENDENT; break; case 'D': Solid|=SOLID_VOLUME_DEPENDENT; break; case 'L': if (isdigit(Switch[2])) FileSizeLess=atoil(Switch+2); break; case 'M': if (isdigit(Switch[2])) FileSizeMore=atoil(Switch+2); break; case 'C': { RAR_CHARSET rch=RCH_DEFAULT; switch(etoupper(Switch[2])) { case 'A': rch=RCH_ANSI; break; case 'O': rch=RCH_OEM; break; case 'U': rch=RCH_UNICODE; break; default : BadSwitch(Switch); break; }; if (Switch[3]==0) CommentCharset=FilelistCharset=rch; else for (int I=3;Switch[I]!=0;I++) switch(etoupper(Switch[I])) { case 'C': CommentCharset=rch; break; case 'L': FilelistCharset=rch; break; default: BadSwitch(Switch); break; } } break; } break; case 'C': if (Switch[2]==0) switch(etoupper(Switch[1])) { case '-': DisableComment=true; break; case 'U': ConvertNames=NAMES_UPPERCASE; break; case 'L': ConvertNames=NAMES_LOWERCASE; break; } break; case 'K': switch(etoupper(Switch[1])) { case 'B': KeepBroken=true; break; case 0: Lock=true; break; } break; #ifndef GUI case '?' : OutHelp(); break; #endif default : BadSwitch(Switch); break; } }
void cVNSIStatus::Action(void) { cTimeMs chanTimer(0); cTimeMs epgTimer(0); // get initial state of the recordings #if VDRVERSNUM >= 20301 cStateKey chanState; const cChannels *channels = cChannels::GetChannelsRead(chanState); chanState.Remove(false); #endif // get initial state of the recordings #if VDRVERSNUM >= 20301 cStateKey recState; const cRecordings *recordings = cRecordings::GetRecordingsRead(recState); recState.Remove(false); #else int recState = -1; Recordings.StateChanged(recState); #endif // get initial state of the timers #if VDRVERSNUM >= 20301 cStateKey timerState; const cTimers *timers = cTimers::GetTimersRead(timerState); timerState.Remove(false); #else int timerState = -1; Timers.Modified(timerState); #endif // vnsitimer int vnsitimerState; m_vnsiTimers->StateChange(vnsitimerState); // last update of epg #if VDRVERSNUM >= 20301 cStateKey epgState; const cSchedules *epg = cSchedules::GetSchedulesRead(epgState); epgState.Remove(false); #else time_t epgUpdate = cSchedules::Modified(); #endif // delete old timeshift file struct stat sb; if ((*TimeshiftBufferDir) && stat(TimeshiftBufferDir, &sb) == 0 && S_ISDIR(sb.st_mode)) { DeleteFiles(TimeshiftBufferDir, ".vnsi"); } else { #if VDRVERSNUM >= 20102 DeleteFiles(cVideoDirectory::Name(), ".vnsi"); #else DeleteFiles(VideoDirectory, ".vnsi"); #endif } // set thread priority SetPriority(1); while (Running()) { m_mutex.Lock(); // remove disconnected clients for (ClientList::iterator i = m_clients.begin(); i != m_clients.end();) { if (!i->Active()) { INFOLOG("Client with ID %u seems to be disconnected, removing from client list", i->GetID()); i = m_clients.erase(i); } else { i++; } } /*! * Don't to updates during running channel scan, KODI's PVR manager becomes * restarted of finished scan. */ if (!cVNSIClient::InhibidDataUpdates()) { // reset inactivity timeout as long as there are clients connected if (!m_clients.empty()) { ShutdownHandler.SetUserInactiveTimeout(); } // trigger clients to reload the modified channel list if(chanTimer.TimedOut()) { #if VDRVERSNUM >= 20301 if (channels->Lock(chanState)) { chanState.Remove(false); INFOLOG("Requesting clients to reload channel list"); for (auto &i : m_clients) i.ChannelsChange(); chanTimer.Set(5000); } #else int modified = Channels.Modified(); if (modified) { Channels.SetModified((modified == CHANNELSMOD_USER) ? true : false); INFOLOG("Requesting clients to reload channel list"); for (auto &i : m_clients) i.ChannelsChange(); } chanTimer.Set(5000); #endif } #if VDRVERSNUM >= 20301 if (recordings->Lock(recState)) { recState.Remove(); INFOLOG("Requesting clients to reload recordings list"); for (auto &i : m_clients) { i.RecordingsChange(); } } if (timers->Lock(timerState)) { timerState.Remove(false); INFOLOG("Requesting clients to reload timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } if (m_vnsiTimers->StateChange(vnsitimerState)) { INFOLOG("Requesting clients to reload vnsi-timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } if (epgTimer.TimedOut()) { if (epg->Lock(epgState)) { epgState.Remove(false); DEBUGLOG("Requesting clients to load epg"); int callAgain = 0; for (auto &i : m_clients) { callAgain |= i.EpgChange(); } if (callAgain & VNSI_EPG_AGAIN) { epgTimer.Set(100); epgState.Reset(); } else { if (callAgain & VNSI_EPG_PAUSE) { epgState.Reset(); } epgTimer.Set(5000); m_vnsiTimers->Scan(); } } } #else // update recordings if(Recordings.StateChanged(recState)) { INFOLOG("Recordings state changed (%i)", recState); INFOLOG("Requesting clients to reload recordings list"); for (auto &i : m_clients) i.RecordingsChange(); } // update timers if(Timers.Modified(timerState)) { INFOLOG("Timers state changed (%i)", timerState); INFOLOG("Requesting clients to reload timers"); for (auto &i : m_clients) { i.SignalTimerChange(); } } // update epg if((cSchedules::Modified() > epgUpdate + 10) || time(NULL) > epgUpdate + 300) { for (auto &i : m_clients) { i.EpgChange(); } epgUpdate = time(NULL); } #endif } m_mutex.Unlock(); usleep(250*1000); } }
void CMediaMonitor::OnStartup() { SetPriority( THREAD_PRIORITY_LOWEST ); }
void CAddonStatusHandler::OnStartup() { SetPriority(GetMinPriority()); }
CLinuxInputDevicesCheckHotplugged::CLinuxInputDevicesCheckHotplugged(CLinuxInputDevices &parent) : CThread("CLinuxInputDevicesCheckHotplugged"), m_parent(parent) { Create(); SetPriority(THREAD_PRIORITY_BELOW_NORMAL); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: { hWndListOne = CreateWindow(L"listbox", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, 5, 10, 380, 430, hWnd, (HMENU)ID_LISTONE, hInst, NULL); hWndListTwo = CreateWindow(L"listbox", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER | WS_VSCROLL | LBS_NOTIFY, 390, 10, 380, 430, hWnd, (HMENU)ID_LISTONE, hInst, NULL); GetProcess(true); }; return 0; case WM_COMMAND: { UINT code = HIWORD(wParam); UINT idCtrl = LOWORD(wParam); int j = 0; switch (idCtrl) { case ID_HIGH: SetPriority(HIGH_PRIORITY_CLASS); break; case ID_IDLE: SetPriority(IDLE_PRIORITY_CLASS); break; case ID_NORMAL: SetPriority(NORMAL_PRIORITY_CLASS); break; case ID_REALTIME: SetPriority(REALTIME_PRIORITY_CLASS); break; case ID_LISTONE: if (code == LBN_DBLCLK) { SendMessage(hWndListTwo, LB_RESETCONTENT, 0, 0); i = SendMessage(hWndListOne, LB_GETCURSEL, 0, 0); if(i<=1024&&i>=0) PrintModules(twar[i]); } break; } }; return 0; case WM_CONTEXTMENU: { HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MFT_STRING, ID_HIGH, L"HIGH"); AppendMenu(hMenu, MFT_STRING, ID_IDLE, L"IDLE"); AppendMenu(hMenu, MFT_STRING, ID_NORMAL, L"NORMAL"); AppendMenu(hMenu, MFT_STRING, ID_REALTIME, L"REALTIME"); TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN, LOWORD(lParam), HIWORD(lParam), 0, hWnd, NULL); DestroyMenu(hMenu); } break; case WM_DESTROY: { PostQuitMessage(0); } break; default: return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; }
void CUdpClient::OnStartup() { SetPriority( GetMinPriority() ); }
//Erhöht/erniedrigt die priorität des prozesses EXPORT_TYPE bool CALL_TYPE PCI_PrioritySet(WORD PriorityLevel) { bool status; status=SetPriority(int(PriorityLevel)); return status; }
void CVNSITimers::Action() { #if VDRVERSNUM >= 20301 bool modified; cStateKey timerState; // set thread priority (nice level) SetPriority(1); while (Running()) { if (!m_doScan) { usleep(1000*1000); continue; } m_doScan = false; std::vector<CVNSITimer> timers; { cMutexLock lock(&m_timerLock); timers = m_timers; } cTimers *Timers = cTimers::GetTimersWrite(timerState); if (!Timers) continue; Timers->SetExplicitModify(); modified = false; cStateKey SchedulesStateKey(true); const cSchedules *schedules = cSchedules::GetSchedulesRead(SchedulesStateKey); if (schedules) { for (const cSchedule *schedule = schedules->First(); schedule; schedule = schedules->Next(schedule)) { for (auto &searchTimer : timers) { if (!searchTimer.m_enabled) continue; if (!(searchTimer.m_channelID == schedule->ChannelID())) continue; for (const cEvent *event = schedule->Events()->First(); event; event = schedule->Events()->Next(event)) { std::string title(event->Title()); std::smatch m; std::regex e(Convert(searchTimer.m_search)); if (std::regex_search(title, m, e, std::regex_constants::match_not_null)) { bool duplicate = false; LOCK_RECORDINGS_READ; for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) { if (recording->Info() != nullptr) { if (strcmp(recording->Info()->Title(), event->Title()) == 0) { if (recording->Info()->ShortText() != nullptr && event->ShortText() != nullptr && strcmp(recording->Info()->ShortText(), event->ShortText()) == 0) { duplicate = true; break; } } } if (abs(difftime(event->StartTime(), recording->Start())) < 300) { duplicate = true; break; } } if (duplicate) continue; if (IsDuplicateEvent(Timers, event)) continue; std::unique_ptr<cTimer> newTimer(new cTimer(event)); Timers->Add(newTimer.release()); modified = true; } } } } } if (modified) Timers->SetModified(); timerState.Remove(modified); SchedulesStateKey.Remove(modified); } #endif }
CPhysicsMotionController::CPhysicsMotionController( IMotionEvent *pHandler, CPhysicsEnvironment *pVEnv ) { m_handler = pHandler; m_pVEnv = pVEnv; SetPriority( MEDIUM_PRIORITY ); }
InputContextPtr InputAPI::RegisterInputContext(const String &name, int priority) { InputContextPtr newInputContext = InputContextPtr(new InputContext(this, name.CString(), priority)); SetPriority(newInputContext, priority); return newInputContext; }
void tTVPAsyncImageLoader::Execute() { // プライオリティは最低にする SetPriority(ttpIdle); LoadingThread(); }
void CUdpClient::OnStartup() { SetPriority( THREAD_PRIORITY_LOWEST ); }
void cXVDRServer::Action(void) { fd_set fds; struct timeval tv; cTimeMs channelReloadTimer; bool channelReloadTrigger = false; SetPriority(19); // get initial state of the recordings int recState = -1; Recordings.StateChanged(recState); // get initial state of the timers int timerState = -1; Timers.Modified(timerState); while (Running()) { FD_ZERO(&fds); FD_SET(m_ServerFD, &fds); tv.tv_sec = 0; tv.tv_usec = 250*1000; int r = select(m_ServerFD + 1, &fds, NULL, NULL, &tv); if (r == -1) { ERRORLOG("failed during select"); continue; } if (r == 0) { // remove disconnected clients for (ClientList::iterator i = m_clients.begin(); i != m_clients.end();) { if (!(*i)->Active()) { INFOLOG("Client with ID %u seems to be disconnected, removing from client list", (*i)->GetID()); delete (*i); i = m_clients.erase(i); } else { i++; } } // trigger clients to reload the modified channel list if(m_clients.size() > 0) { Channels.Lock(false); if(Channels.Modified() != 0) { channelReloadTrigger = true; channelReloadTimer.Set(0); } if(channelReloadTrigger && channelReloadTimer.Elapsed() >= 10*1000) { INFOLOG("Checking for channel updates ..."); for (ClientList::iterator i = m_clients.begin(); i != m_clients.end(); i++) (*i)->ChannelChange(); channelReloadTrigger = false; INFOLOG("Done."); } Channels.Unlock(); } // reset inactivity timeout as long as there are clients connected if(m_clients.size() > 0) { ShutdownHandler.SetUserInactiveTimeout(); } // update recordings if(Recordings.StateChanged(recState)) { INFOLOG("Recordings state changed (%i)", recState); INFOLOG("Requesting clients to reload recordings list"); for (ClientList::iterator i = m_clients.begin(); i != m_clients.end(); i++) (*i)->RecordingsChange(); } // update timers if(Timers.Modified(timerState)) { INFOLOG("Timers state changed (%i)", timerState); INFOLOG("Requesting clients to reload timers"); for (ClientList::iterator i = m_clients.begin(); i != m_clients.end(); i++) { (*i)->TimerChange(); } } continue; } int fd = accept(m_ServerFD, 0, 0); if (fd >= 0) { NewClientConnected(fd); } else { ERRORLOG("accept failed"); } } return; }
/**************************************************************************** * Function: WorkerThread * * Description: * Implements a thread pool worker. * Worker waits for a job to become available. * Worker picks up persistent jobs first, high priority, med priority, * then low priority. * If worker remains idle for more than specified max, the worker * is released. * Internal Only. * Parameters: * void * arg -> is cast to ThreadPool * *****************************************************************************/ static void *WorkerThread( void *arg ) { time_t start = 0; ThreadPoolJob *job = NULL; ListNode *head = NULL; struct timespec timeout; int retCode = 0; int persistent = -1; ThreadPool *tp = ( ThreadPool *) arg; // allow static linking #ifdef WIN32 #ifdef PTW32_STATIC_LIB pthread_win32_thread_attach_np(); #endif #endif assert( tp != NULL ); // Increment total thread count ithread_mutex_lock( &tp->mutex ); tp->totalThreads++; ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); SetSeed(); StatsTime( &start ); while( 1 ) { ithread_mutex_lock( &tp->mutex ); if( job ) { FreeThreadPoolJob( tp, job ); job = NULL; } retCode = 0; tp->stats.idleThreads++; tp->stats.totalWorkTime += ( StatsTime( NULL ) - start ); // work time StatsTime( &start ); // idle time if( persistent == 1 ) { // Persistent thread // becomes a regular thread tp->persistentThreads--; } if( persistent == 0 ) { tp->stats.workerThreads--; } // Check for a job or shutdown while( tp->lowJobQ.size == 0 && tp->medJobQ.size == 0 && tp->highJobQ.size == 0 && !tp->persistentJob && !tp->shutdown ) { // If wait timed out // and we currently have more than the // min threads, or if we have more than the max threads // (only possible if the attributes have been reset) // let this thread die. if( ( retCode == ETIMEDOUT && tp->totalThreads > tp->attr.minThreads ) || ( tp->attr.maxThreads != -1 && tp->totalThreads > tp->attr.maxThreads ) ) { tp->stats.idleThreads--; tp->totalThreads--; ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); #ifdef WIN32 #ifdef PTW32_STATIC_LIB // allow static linking pthread_win32_thread_detach_np (); #endif #endif return NULL; } SetRelTimeout( &timeout, tp->attr.maxIdleTime ); // wait for a job up to the specified max time retCode = ithread_cond_timedwait( &tp->condition, &tp->mutex, &timeout ); } tp->stats.idleThreads--; tp->stats.totalIdleTime += ( StatsTime( NULL ) - start ); // idle time StatsTime( &start ); // work time // bump priority of starved jobs BumpPriority( tp ); // if shutdown then stop if( tp->shutdown ) { tp->totalThreads--; ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); #ifdef WIN32 #ifdef PTW32_STATIC_LIB // allow static linking pthread_win32_thread_detach_np (); #endif #endif return NULL; } else { // Pick up persistent job if available if( tp->persistentJob ) { job = tp->persistentJob; tp->persistentJob = NULL; tp->persistentThreads++; persistent = 1; ithread_cond_broadcast( &tp->start_and_shutdown ); } else { tp->stats.workerThreads++; persistent = 0; // Pick the highest priority job if( tp->highJobQ.size > 0 ) { head = ListHead( &tp->highJobQ ); job = ( ThreadPoolJob *) head->item; CalcWaitTime( tp, HIGH_PRIORITY, job ); ListDelNode( &tp->highJobQ, head, 0 ); } else if( tp->medJobQ.size > 0 ) { head = ListHead( &tp->medJobQ ); job = ( ThreadPoolJob *) head->item; CalcWaitTime( tp, MED_PRIORITY, job ); ListDelNode( &tp->medJobQ, head, 0 ); } else if( tp->lowJobQ.size > 0 ) { head = ListHead( &tp->lowJobQ ); job = ( ThreadPoolJob *) head->item; CalcWaitTime( tp, LOW_PRIORITY, job ); ListDelNode( &tp->lowJobQ, head, 0 ); } else { // Should never get here assert( 0 ); tp->stats.workerThreads--; tp->totalThreads--; ithread_cond_broadcast( &tp->start_and_shutdown ); ithread_mutex_unlock( &tp->mutex ); return NULL; } } } ithread_mutex_unlock( &tp->mutex ); if( SetPriority( job->priority ) != 0 ) { // In the future can log // info } else { // In the future can log // info } // run the job job->func( job->arg ); // return to Normal SetPriority( DEFAULT_PRIORITY ); } }
//--------------------------------------------------------------------------- tTVPWatchThread::tTVPWatchThread() : tTVPThread(true) { TVPWatchLastTick = TVPGetRoughTickCount32(); SetPriority(ttpNormal); Resume(); }
/*! * \brief Implements a thread pool worker. Worker waits for a job to become * available. Worker picks up persistent jobs first, high priority, * med priority, then low priority. * * If worker remains idle for more than specified max, the worker is released. * * \internal */ static void *WorkerThread( /*! arg -> is cast to (ThreadPool *). */ void *arg) { time_t start = 0; ThreadPoolJob *job = NULL; ListNode *head = NULL; struct timespec timeout; int retCode = 0; int persistent = -1; ThreadPool *tp = (ThreadPool *) arg; ithread_initialize_thread(); /* Increment total thread count */ ithread_mutex_lock(&tp->mutex); tp->totalThreads++; tp->pendingWorkerThreadStart = 0; ithread_cond_broadcast(&tp->start_and_shutdown); ithread_mutex_unlock(&tp->mutex); SetSeed(); StatsTime(&start); while (1) { ithread_mutex_lock(&tp->mutex); if (job) { tp->busyThreads--; FreeThreadPoolJob(tp, job); job = NULL; } retCode = 0; tp->stats.idleThreads++; tp->stats.totalWorkTime += (double)StatsTime(NULL) - (double)start; StatsTime(&start); if (persistent == 0) { tp->stats.workerThreads--; } else if (persistent == 1) { /* Persistent thread becomes a regular thread */ tp->persistentThreads--; } /* Check for a job or shutdown */ while (tp->lowJobQ.size == 0 && tp->medJobQ.size == 0 && tp->highJobQ.size == 0 && !tp->persistentJob && !tp->shutdown) { /* If wait timed out and we currently have more than the * min threads, or if we have more than the max threads * (only possible if the attributes have been reset) * let this thread die. */ if ((retCode == ETIMEDOUT && tp->totalThreads > tp->attr.minThreads) || (tp->attr.maxThreads != -1 && tp->totalThreads > tp->attr.maxThreads)) { tp->stats.idleThreads--; goto exit_function; } SetRelTimeout(&timeout, tp->attr.maxIdleTime); /* wait for a job up to the specified max time */ retCode = ithread_cond_timedwait( &tp->condition, &tp->mutex, &timeout); } tp->stats.idleThreads--; /* idle time */ tp->stats.totalIdleTime += (double)StatsTime(NULL) - (double)start; /* work time */ StatsTime(&start); /* bump priority of starved jobs */ BumpPriority(tp); /* if shutdown then stop */ if (tp->shutdown) { goto exit_function; } else { /* Pick up persistent job if available */ if (tp->persistentJob) { job = tp->persistentJob; tp->persistentJob = NULL; tp->persistentThreads++; persistent = 1; ithread_cond_broadcast(&tp->start_and_shutdown); } else { tp->stats.workerThreads++; persistent = 0; /* Pick the highest priority job */ if (tp->highJobQ.size > 0) { head = ListHead(&tp->highJobQ); if (head == NULL) { tp->stats.workerThreads--; goto exit_function; } job = (ThreadPoolJob *) head->item; CalcWaitTime(tp, HIGH_PRIORITY, job); ListDelNode(&tp->highJobQ, head, 0); } else if (tp->medJobQ.size > 0) { head = ListHead(&tp->medJobQ); if (head == NULL) { tp->stats.workerThreads--; goto exit_function; } job = (ThreadPoolJob *) head->item; CalcWaitTime(tp, MED_PRIORITY, job); ListDelNode(&tp->medJobQ, head, 0); } else if (tp->lowJobQ.size > 0) { head = ListHead(&tp->lowJobQ); if (head == NULL) { tp->stats.workerThreads--; goto exit_function; } job = (ThreadPoolJob *) head->item; CalcWaitTime(tp, LOW_PRIORITY, job); ListDelNode(&tp->lowJobQ, head, 0); } else { /* Should never get here */ tp->stats.workerThreads--; goto exit_function; } } } tp->busyThreads++; ithread_mutex_unlock(&tp->mutex); /* In the future can log info */ if (SetPriority(job->priority) != 0) { } else { } /* run the job */ job->func(job->arg); /* return to Normal */ SetPriority(DEFAULT_PRIORITY); } exit_function: tp->totalThreads--; ithread_cond_broadcast(&tp->start_and_shutdown); ithread_mutex_unlock(&tp->mutex); ithread_cleanup_thread(); return NULL; }
void cXVDRData::Action() { uint32_t lastPing = 0; cResponsePacket* vresp; SetPriority(19); while (Running()) { // try to reconnect if(ConnectionLost() && !TryReconnect()) { SleepMs(1000); continue; } // read message vresp = cXVDRSession::ReadMessage(); // check if the connection is still up if (vresp == NULL) { if(time(NULL) - lastPing > 5) { lastPing = time(NULL); if(!SendPing()) SignalConnectionLost(); } continue; } // CHANNEL_REQUEST_RESPONSE if (vresp->getChannelID() == XVDR_CHANNEL_REQUEST_RESPONSE) { CMD_LOCK; SMessages::iterator it = m_queue.find(vresp->getRequestID()); if (it != m_queue.end()) { it->second.pkt = vresp; it->second.event->Signal(); } else { delete vresp; } } // CHANNEL_STATUS else if (vresp->getChannelID() == XVDR_CHANNEL_STATUS) { if (vresp->getRequestID() == XVDR_STATUS_MESSAGE) { uint32_t type = vresp->extract_U32(); char* msgstr = vresp->extract_String(); std::string text = msgstr; if (type == 2) XBMC->QueueNotification(QUEUE_ERROR, text.c_str()); if (type == 1) XBMC->QueueNotification(QUEUE_WARNING, text.c_str()); else XBMC->QueueNotification(QUEUE_INFO, text.c_str()); delete[] msgstr; } else if (vresp->getRequestID() == XVDR_STATUS_RECORDING) { vresp->extract_U32(); // device currently unused uint32_t on = vresp->extract_U32(); char* str1 = vresp->extract_String(); char* str2 = vresp->extract_String(); PVR->Recording(str1, str2, on); PVR->TriggerTimerUpdate(); delete[] str1; delete[] str2; } else if (vresp->getRequestID() == XVDR_STATUS_TIMERCHANGE) { XBMC->Log(LOG_DEBUG, "Server requested timer update"); PVR->TriggerTimerUpdate(); } else if (vresp->getRequestID() == XVDR_STATUS_CHANNELCHANGE) { XBMC->Log(LOG_DEBUG, "Server requested channel update"); PVR->TriggerChannelUpdate(); } else if (vresp->getRequestID() == XVDR_STATUS_RECORDINGSCHANGE) { XBMC->Log(LOG_DEBUG, "Server requested recordings update"); PVR->TriggerRecordingUpdate(); } delete vresp; } // UNKOWN CHANNELID else if (!OnResponsePacket(vresp)) { XBMC->Log(LOG_ERROR, "%s - Rxd a response packet on channel %lu !!", __FUNCTION__, vresp->getChannelID()); delete vresp; } } }
int CgptPrioritize(CgptPrioritizeParams *params) { struct drive drive; int priority; int gpt_retval; uint32_t index; uint32_t max_part; int num_root; int i,j; group_list_t *groups; if (params == NULL) return CGPT_FAILED; if (CGPT_OK != DriveOpen(params->drive_name, &drive, 0, O_RDWR)) return CGPT_FAILED; if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) { Error("GptSanityCheck() returned %d: %s\n", gpt_retval, GptError(gpt_retval)); return CGPT_FAILED; } max_part = GetNumberOfEntries(&drive); if (params->set_partition) { if (params->set_partition < 1 || params->set_partition > max_part) { Error("invalid partition number: %d (must be between 1 and %d\n", params->set_partition, max_part); goto bad; } index = params->set_partition - 1; // it must be a kernel if (!IsRoot(&drive, PRIMARY, index) && !IsMarker(&drive, PRIMARY, index)) { Error("partition %d is not a valid root\n", params->set_partition); goto bad; } } // How many kernel partitions do I have? num_root = 0; for (i = 0; i < max_part; i++) { if (IsRoot(&drive, PRIMARY, i) || IsMarker(&drive, PRIMARY, i)) num_root++; } if (num_root) { // Determine the current priority groups groups = NewGroupList(num_root); for (i = 0; i < max_part; i++) { if (!IsRoot(&drive, PRIMARY, i) && !IsMarker(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i); // Is this partition special? if (params->set_partition && (i+1 == params->set_partition)) { params->orig_priority = priority; // remember the original priority if (params->set_friends) AddToGroup(groups, priority, i); // we'll move them all later else AddToGroup(groups, 99, i); // move only this one } else { AddToGroup(groups, priority, i); // just remember } } // If we're including friends, then change the original group priority if (params->set_partition && params->set_friends) { ChangeGroup(groups, params->orig_priority, 99); } // Sorting gives the new order. Now we just need to reassign the // priorities. SortGroups(groups); // We'll never lower anything to zero, so if the last group is priority zero // we can ignore it. i = groups->num_groups; if (groups->group[i-1].priority == 0) groups->num_groups--; // Where do we start? if (params->max_priority) priority = params->max_priority; else priority = groups->num_groups > 15 ? 15 : groups->num_groups; // Figure out what the new values should be for (i=0; i<groups->num_groups; i++) { groups->group[i].priority = priority; if (priority > 1) priority--; } // Now apply the ranking to the GPT for (i=0; i<groups->num_groups; i++) for (j=0; j<groups->group[i].num_parts; j++) SetPriority(&drive, PRIMARY, groups->group[i].part[j], groups->group[i].priority); FreeGroups(groups); } // Write it all out UpdateAllEntries(&drive); return DriveClose(&drive, 1); bad: (void) DriveClose(&drive, 0); return CGPT_FAILED; }
void CommandData::ProcessSwitch(const wchar *Switch) { switch(toupperw(Switch[0])) { case '@': ListMode=Switch[1]=='+' ? RCLM_ACCEPT_LISTS:RCLM_REJECT_LISTS; break; case 'A': switch(toupperw(Switch[1])) { case 'C': ClearArc=true; break; case 'D': AppendArcNameToPath=true; break; #ifndef SFX_MODULE case 'G': if (Switch[2]=='-' && Switch[3]==0) GenerateArcName=0; else { GenerateArcName=true; wcsncpyz(GenerateMask,Switch+2,ASIZE(GenerateMask)); } break; #endif case 'I': IgnoreGeneralAttr=true; break; case 'N': // Reserved for archive name. break; case 'O': AddArcOnly=true; break; case 'P': wcscpy(ArcPath,Switch+2); break; case 'S': SyncFiles=true; break; default: BadSwitch(Switch); break; } break; case 'C': if (Switch[2]==0) switch(toupperw(Switch[1])) { case '-': DisableComment=true; break; case 'U': ConvertNames=NAMES_UPPERCASE; break; case 'L': ConvertNames=NAMES_LOWERCASE; break; } break; case 'D': if (Switch[2]==0) switch(toupperw(Switch[1])) { case 'S': DisableSortSolid=true; break; case 'H': OpenShared=true; break; case 'F': DeleteFiles=true; break; } break; case 'E': switch(toupperw(Switch[1])) { case 'P': switch(Switch[2]) { case 0: ExclPath=EXCL_SKIPWHOLEPATH; break; case '1': ExclPath=EXCL_BASEPATH; break; case '2': ExclPath=EXCL_SAVEFULLPATH; break; case '3': ExclPath=EXCL_ABSPATH; break; } break; default: if (Switch[1]=='+') { InclFileAttr|=GetExclAttr(Switch+2); InclAttrSet=true; } else ExclFileAttr|=GetExclAttr(Switch+1); break; } break; case 'F': if (Switch[1]==0) FreshFiles=true; else BadSwitch(Switch); break; case 'H': switch (toupperw(Switch[1])) { case 'P': EncryptHeaders=true; if (Switch[2]!=0) { Password.Set(Switch+2); cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0])); } else if (!Password.IsSet()) { uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password); eprintf(L"\n"); } break; default : BadSwitch(Switch); break; } break; case 'I': if (wcsnicomp(Switch+1,L"LOG",3)==0) { wcsncpyz(LogName,Switch[4]!=0 ? Switch+4:DefLogName,ASIZE(LogName)); break; } if (wcsicomp(Switch+1,L"SND")==0) { Sound=true; break; } if (wcsicomp(Switch+1,L"ERR")==0) { MsgStream=MSG_STDERR; break; } if (wcsnicomp(Switch+1,L"EML",3)==0) { wcsncpyz(EmailTo,Switch[4]!=0 ? Switch+4:L"@",ASIZE(EmailTo)); break; } if (wcsicomp(Switch+1,L"NUL")==0) { MsgStream=MSG_NULL; break; } if (toupperw(Switch[1])=='D') { for (uint I=2;Switch[I]!=0;I++) switch(toupperw(Switch[I])) { case 'Q': MsgStream=MSG_ERRONLY; break; case 'C': DisableCopyright=true; break; case 'D': DisableDone=true; break; case 'P': DisablePercentage=true; break; } break; } if (wcsicomp(Switch+1,L"OFF")==0) { Shutdown=true; break; } if (wcsicomp(Switch+1,L"VER")==0) { PrintVersion=true; break; } break; case 'K': switch(toupperw(Switch[1])) { case 'B': KeepBroken=true; break; case 0: Lock=true; break; } break; case 'M': switch(toupperw(Switch[1])) { case 'C': { const wchar *Str=Switch+2; if (*Str=='-') for (uint I=0;I<ASIZE(FilterModes);I++) FilterModes[I].State=FILTER_DISABLE; else while (*Str!=0) { int Param1=0,Param2=0; FilterState State=FILTER_AUTO; FilterType Type=FILTER_NONE; if (IsDigit(*Str)) { Param1=atoiw(Str); while (IsDigit(*Str)) Str++; } if (*Str==':' && IsDigit(Str[1])) { Param2=atoiw(++Str); while (IsDigit(*Str)) Str++; } switch(toupperw(*(Str++))) { case 'T': Type=FILTER_PPM; break; case 'E': Type=FILTER_E8; break; case 'D': Type=FILTER_DELTA; break; case 'A': Type=FILTER_AUDIO; break; case 'C': Type=FILTER_RGB; break; case 'I': Type=FILTER_ITANIUM; break; case 'R': Type=FILTER_ARM; break; } if (*Str=='+' || *Str=='-') State=*(Str++)=='+' ? FILTER_FORCE:FILTER_DISABLE; FilterModes[Type].State=State; FilterModes[Type].Param1=Param1; FilterModes[Type].Param2=Param2; } } break; case 'M': break; case 'D': break; case 'S': { wchar StoreNames[1024]; wcsncpyz(StoreNames,(Switch[2]==0 ? DefaultStoreList:Switch+2),ASIZE(StoreNames)); wchar *Names=StoreNames; while (*Names!=0) { wchar *End=wcschr(Names,';'); if (End!=NULL) *End=0; if (*Names=='.') Names++; wchar Mask[NM]; if (wcspbrk(Names,L"*?.")==NULL) swprintf(Mask,ASIZE(Mask),L"*.%ls",Names); else wcsncpyz(Mask,Names,ASIZE(Mask)); StoreArgs.AddString(Mask); if (End==NULL) break; Names=End+1; } } break; #ifdef RAR_SMP case 'T': Threads=atoiw(Switch+2); if (Threads>MaxPoolThreads || Threads<1) BadSwitch(Switch); else { } break; #endif default: Method=Switch[1]-'0'; if (Method>5 || Method<0) BadSwitch(Switch); break; } break; case 'N': case 'X': if (Switch[1]!=0) { StringList *Args=toupperw(Switch[0])=='N' ? &InclArgs:&ExclArgs; if (Switch[1]=='@' && !IsWildcard(Switch)) { RAR_CHARSET Charset=FilelistCharset; #if defined(_WIN_ALL) && !defined(GUI) // for compatibility reasons we use OEM encoding // in Win32 console version by default // if (Charset==RCH_DEFAULT) // Charset=RCH_OEM; #endif ReadTextFile(Switch+2,Args,false,true,Charset,true,true,true); } else Args->AddString(Switch+1); } break; case 'O': switch(toupperw(Switch[1])) { case '+': Overwrite=OVERWRITE_ALL; break; case '-': Overwrite=OVERWRITE_NONE; break; case 0: Overwrite=OVERWRITE_FORCE_ASK; break; #ifdef _WIN_ALL case 'C': SetCompressedAttr=true; break; #endif case 'H': SaveHardLinks=true; break; #ifdef SAVE_LINKS case 'L': SaveSymLinks=true; if (toupperw(Switch[2])=='A') AbsoluteLinks=true; break; #endif #ifdef _WIN_ALL case 'N': if (toupperw(Switch[2])=='I') AllowIncompatNames=true; break; #endif case 'R': Overwrite=OVERWRITE_AUTORENAME; break; #ifdef _WIN_ALL case 'S': SaveStreams=true; break; #endif case 'W': ProcessOwners=true; break; default : BadSwitch(Switch); break; } break; case 'P': if (Switch[1]==0) { uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password); eprintf(L"\n"); } else { Password.Set(Switch+1); cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0])); } break; #ifndef SFX_MODULE case 'Q': if (toupperw(Switch[1])=='O') switch(toupperw(Switch[2])) { case 0: QOpenMode=QOPEN_AUTO; break; case '-': QOpenMode=QOPEN_NONE; break; case '+': QOpenMode=QOPEN_ALWAYS; break; default: BadSwitch(Switch); break; } else BadSwitch(Switch); break; #endif case 'R': switch(toupperw(Switch[1])) { case 0: Recurse=RECURSE_ALWAYS; break; case '-': Recurse=RECURSE_DISABLE; break; case '0': Recurse=RECURSE_WILDCARDS; break; case 'I': { Priority=atoiw(Switch+2); if (Priority<0 || Priority>15) BadSwitch(Switch); const wchar *ChPtr=wcschr(Switch+2,':'); if (ChPtr!=NULL) { SleepTime=atoiw(ChPtr+1); if (SleepTime>1000) BadSwitch(Switch); InitSystemOptions(SleepTime); } SetPriority(Priority); } break; } break; case 'S': if (IsDigit(Switch[1])) { Solid|=SOLID_COUNT; SolidCount=atoiw(&Switch[1]); } else switch(toupperw(Switch[1])) { case 0: Solid|=SOLID_NORMAL; break; case '-': Solid=SOLID_NONE; break; case 'E': Solid|=SOLID_FILEEXT; break; case 'V': Solid|=Switch[2]=='-' ? SOLID_VOLUME_DEPENDENT:SOLID_VOLUME_INDEPENDENT; break; case 'D': Solid|=SOLID_VOLUME_DEPENDENT; break; case 'L': if (IsDigit(Switch[2])) FileSizeLess=atoilw(Switch+2); break; case 'M': if (IsDigit(Switch[2])) FileSizeMore=atoilw(Switch+2); break; case 'C': { bool AlreadyBad=false; // Avoid reporting "bad switch" several times. RAR_CHARSET rch=RCH_DEFAULT; switch(toupperw(Switch[2])) { case 'A': rch=RCH_ANSI; break; case 'O': rch=RCH_OEM; break; case 'U': rch=RCH_UNICODE; break; default : BadSwitch(Switch); AlreadyBad=true; break; }; if (!AlreadyBad) if (Switch[3]==0) CommentCharset=FilelistCharset=ErrlogCharset=rch; else for (uint I=3;Switch[I]!=0 && !AlreadyBad;I++) switch(toupperw(Switch[I])) { case 'C': CommentCharset=rch; break; case 'L': FilelistCharset=rch; break; case 'R': RedirectCharset=rch; break; default: BadSwitch(Switch); AlreadyBad=true; break; } } break; } break; case 'T': switch(toupperw(Switch[1])) { case 'K': ArcTime=ARCTIME_KEEP; break; case 'L': ArcTime=ARCTIME_LATEST; break; case 'O': FileTimeBefore.SetAgeText(Switch+2); break; case 'N': FileTimeAfter.SetAgeText(Switch+2); break; case 'B': FileTimeBefore.SetIsoText(Switch+2); break; case 'A': FileTimeAfter.SetIsoText(Switch+2); break; case 'S': { EXTTIME_MODE Mode=EXTTIME_HIGH3; bool CommonMode=Switch[2]>='0' && Switch[2]<='4'; if (CommonMode) Mode=(EXTTIME_MODE)(Switch[2]-'0'); if (Switch[2]=='-') Mode=EXTTIME_NONE; if (CommonMode || Switch[2]=='-' || Switch[2]=='+' || Switch[2]==0) xmtime=xctime=xatime=Mode; else { if (Switch[3]>='0' && Switch[3]<='4') Mode=(EXTTIME_MODE)(Switch[3]-'0'); if (Switch[3]=='-') Mode=EXTTIME_NONE; switch(toupperw(Switch[2])) { case 'M': xmtime=Mode; break; case 'C': xctime=Mode; break; case 'A': xatime=Mode; break; } } } break; case '-': Test=false; break; case 0: Test=true; break; default: BadSwitch(Switch); break; } break; case 'U': if (Switch[1]==0) UpdateFiles=true; else BadSwitch(Switch); break; case 'V': switch(toupperw(Switch[1])) { case 'P': VolumePause=true; break; case 'A': if (toupperw(Switch[2])=='P') { VolumeAutoPause=true; if (IsDigit(Switch[3])) { VolumeAutoPauseInterval=atoiw(Switch+3); } else { VolumeAutoPauseInterval=5; } } break; case 'E': if (toupperw(Switch[2])=='R') VersionControl=atoiw(Switch+3)+1; break; case '-': VolSize=0; break; default: VolSize=VOLSIZE_AUTO; // UnRAR -v switch for list command. break; } break; case 'W': wcsncpyz(TempPath,Switch+1,ASIZE(TempPath)); AddEndSlash(TempPath,ASIZE(TempPath)); break; case 'Y': AllYes=true; break; case 'Z': if (Switch[1]==0) { #ifndef GUI // stdin is not supported by WinRAR. // If comment file is not specified, we read data from stdin. wcscpy(CommentFile,L"stdin"); #endif } else wcsncpyz(CommentFile,Switch+1,ASIZE(CommentFile)); break; #ifndef GUI case '?' : OutHelp(RARX_SUCCESS); break; #endif default : BadSwitch(Switch); break; } }
NS_IMETHODIMP HttpBaseChannel::AdjustPriority(PRInt32 delta) { return SetPriority(mPriority + delta); }
// -------------------------------------------------------------------------------- // guSmartModeThread::guSmartModeThread( guDbLibrary * db, wxEvtHandler * owner, const wxString &artistname, const wxString &trackname, wxArrayInt * smartaddedtracks, wxArrayString * smartaddedartists, const int maxtracks, const int maxartists, const double tracklimit, const int limittype, const int filterallow, const int filterdeny, const int gaugeid ) : wxThread() { //guLogMessage( wxT( "guSmartModeThread::guSmartModeThread" ) ); m_Db = db; m_Owner = owner; m_ArtistName = wxString( artistname.c_str() ); m_TrackName = wxString( trackname.c_str() ); m_SmartAddedTracks = smartaddedtracks; m_SmartAddedArtists = smartaddedartists; m_MaxSmartTracksList = maxtracks; m_MaxSmartArtistsList = maxartists; m_FilterAllowPlayList = filterallow; m_FilterDenyPlayList = filterdeny; m_GaugeId = gaugeid; m_LimitType = limittype; switch( limittype ) { case guSMARTMODE_TRACK_LIMIT_TIME_MINUTES : m_TrackLimit.Assign( tracklimit * 60000 ); break; case guSMARTMODE_TRACK_LIMIT_TIME_HOURS : m_TrackLimit.Assign( tracklimit * 60 * 60000 ); break; case guSMARTMODE_TRACK_LIMIT_SIZE_MB : m_TrackLimit.Assign( tracklimit * 1024 * 1024 ); break; case guSMARTMODE_TRACK_LIMIT_SIZE_GB : m_TrackLimit.Assign( tracklimit * 1024 * 1024 * 1024 ); break; //case guSMARTMODE_TRACK_LIMIT_TRACKS : default : m_TrackLimit.Assign( tracklimit ); m_LimitType = guSMARTMODE_TRACK_LIMIT_TRACKS; break; } m_LimitCounter = 0; m_LimitReached = false; if( gaugeid != wxNOT_FOUND ) { wxCommandEvent Event( wxEVT_COMMAND_MENU_SELECTED, ID_STATUSBAR_GAUGE_SETMAX ); Event.SetInt( m_GaugeId ); Event.SetExtraLong( m_TrackLimit.GetLo() ); wxPostEvent( guMainFrame::GetMainFrame(), Event ); } m_LastFM = new guLastFM(); if( Create() == wxTHREAD_NO_ERROR ) { SetPriority( WXTHREAD_DEFAULT_PRIORITY - 30 ); Run(); } }