// Called when the game starts or when spawned void AZombieCharacter::BeginPlay() { Super::BeginPlay(); //ParticleSystemComponent->SetWorldLocation(GetActorLocation()); ParticleSystemComponent->SetRelativeLocation(FVector(90, 0, 40)); AudioComponent->SetRelativeLocation(FVector(90, 0, 40)); //Stats initialization StatsInit(MinHealth, MaxHealth, MinDamage, MaxDamage); CurrentSpeed = FMath::RandRange(MinSpeed, MaxSpeed); bHasDot = false; bHasSlow = false; InitialMaxWalkSpeed = CurrentSpeed; GetCharacterMovement()->MaxWalkSpeed = CurrentSpeed; //Animations initialization ZAnimInstance = Cast<UZombieAnimInstance>(GetMesh()->GetAnimInstance()); ZAnimInstance->Speed = CurrentSpeed; //Setting up the player reference for future use OurCharacter = Cast<AZombieController>(GetController())->GetTarget(); if(AlphaReductionCurveFloat && DeathMaterialInstance) { //Binds the functions for the progress and the finished function on the timeline FOnTimelineFloat TimelineFunctionProgress; TimelineFunctionProgress.BindUFunction(this, FName("HandleTimelineProgress")); FOnTimelineEvent CompletedTimelineEvent; CompletedTimelineEvent.BindUFunction(this, FName("Destroy")); //Binding... AlphaReductionTimeline.AddInterpFloat(AlphaReductionCurveFloat, TimelineFunctionProgress); AlphaReductionTimeline.SetTimelineFinishedFunc(CompletedTimelineEvent); } }
void StatsInitGame(void) { StatsInit(); #ifndef USE_C_CORE uint32_t reason; uint32_t area; for (area = 0; area < TRANSLATION_REGION_COUNT; area++) { Stats.TranslationBytesFlushed[area] = 0; Stats.TranslationBytesPeak[area] = 0; for (reason = 0; reason < CACHE_FLUSH_REASON_COUNT; reason++) { Stats.TranslationFlushCount[area][reason] = 0; } } for (area = 0; area < METADATA_AREA_COUNT; area++) { for (reason = 0; reason < METADATA_CLEAR_REASON_COUNT; reason++) { Stats.MetadataClearCount[area][reason] = 0; } } Stats.PartialFlushCount = 0; #endif Stats.SoundBufferUnderrunCount = 0; Stats.InSoundBufferUnderrun = 0; Stats.TotalEmulatedFrames = 0; Stats.TotalRenderedFrames = 0; #ifdef PERFORMANCE_IMPACTING_STATISTICS Stats.ARMOpcodesDecoded = 0; Stats.ThumbOpcodesDecoded = 0; Stats.ThumbROMConstants = 0; Stats.BlockReuseCount = 0; Stats.BlockRecompilationCount = 0; Stats.OpcodeReuseCount = 0; Stats.OpcodeRecompilationCount = 0; Stats.WrongAddressLineCount = 0; #endif }
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr) { int retCode = 0; int i = 0; if (!tp) { return EINVAL; } retCode += ithread_mutex_init(&tp->mutex, NULL); retCode += ithread_mutex_lock(&tp->mutex); retCode += ithread_cond_init(&tp->condition, NULL); retCode += ithread_cond_init(&tp->start_and_shutdown, NULL); if (retCode) { ithread_mutex_unlock(&tp->mutex); ithread_mutex_destroy(&tp->mutex); ithread_cond_destroy(&tp->condition); ithread_cond_destroy(&tp->start_and_shutdown); return EAGAIN; } if (attr) { tp->attr = *attr; } else { TPAttrInit(&tp->attr); } if (SetPolicyType(tp->attr.schedPolicy) != 0) { ithread_mutex_unlock(&tp->mutex); ithread_mutex_destroy(&tp->mutex); ithread_cond_destroy(&tp->condition); ithread_cond_destroy(&tp->start_and_shutdown); return INVALID_POLICY; } retCode += FreeListInit( &tp->jobFreeList, sizeof(ThreadPoolJob), JOBFREELISTSIZE); StatsInit(&tp->stats); retCode += ListInit(&tp->highJobQ, CmpThreadPoolJob, NULL); retCode += ListInit(&tp->medJobQ, CmpThreadPoolJob, NULL); retCode += ListInit(&tp->lowJobQ, CmpThreadPoolJob, NULL); if (retCode) { retCode = EAGAIN; } else { tp->persistentJob = NULL; tp->lastJobId = 0; tp->shutdown = 0; tp->totalThreads = 0; tp->busyThreads = 0; tp->persistentThreads = 0; tp->pendingWorkerThreadStart = 0; for (i = 0; i < tp->attr.minThreads; ++i) { retCode = CreateWorker(tp); if (retCode) { break; } } } ithread_mutex_unlock(&tp->mutex); if (retCode) { /* clean up if the min threads could not be created */ ThreadPoolShutdown(tp); } return retCode; }
/**************************************************************************** * Function: ThreadPoolInit * * Description: * Initializes and starts ThreadPool. Must be called first. * And only once for ThreadPool. * Parameters: * tp - must be valid, non null, pointer to ThreadPool. * minWorkerThreads - minimum number of worker threads * thread pool will never have less than this * number of threads. * maxWorkerThreads - maximum number of worker threads * thread pool will never have more than this * number of threads. * maxIdleTime - maximum time that a worker thread will spend * idle. If a worker is idle longer than this * time and there are more than the min * number of workers running, than the * worker thread exits. * jobsPerThread - ratio of jobs to thread to try and maintain * if a job is scheduled and the number of jobs per * thread is greater than this number,and * if less than the maximum number of * workers are running then a new thread is * started to help out with efficiency. * schedPolicy - scheduling policy to try and set (OS dependent) * Returns: * 0 on success, nonzero on failure. * EAGAIN if not enough system resources to create minimum threads. * INVALID_POLICY if schedPolicy can't be set * EMAXTHREADS if minimum threads is greater than maximum threads *****************************************************************************/ int ThreadPoolInit( ThreadPool *tp, ThreadPoolAttr *attr ) { int retCode = 0; int i = 0; //printf("%s, %d\n", __FUNCTION__, __LINE__); assert( tp != NULL ); if( tp == NULL ) { return EINVAL; } #ifdef WIN32 #ifdef PTW32_STATIC_LIB pthread_win32_process_attach_np(); #endif #endif //printf("%s, %d\n", __FUNCTION__, __LINE__); retCode += ithread_mutex_init( &tp->mutex, NULL ); assert( retCode == 0 ); retCode += ithread_mutex_lock( &tp->mutex ); assert( retCode == 0 ); retCode += ithread_cond_init( &tp->condition, NULL ); assert( retCode == 0 ); retCode += ithread_cond_init( &tp->start_and_shutdown, NULL ); assert( retCode == 0 ); //printf("%s, %d\n", __FUNCTION__, __LINE__); if( retCode != 0 ) { return EAGAIN; } if( attr ) { tp->attr = ( *attr ); } else { TPAttrInit( &tp->attr ); } //printf("%s, %d, minthreads: %d\n", __FUNCTION__, __LINE__, tp->attr.minThreads); if( SetPolicyType( tp->attr.schedPolicy ) != 0 ) { ithread_mutex_unlock( &tp->mutex ); ithread_mutex_destroy( &tp->mutex ); ithread_cond_destroy( &tp->condition ); ithread_cond_destroy( &tp->start_and_shutdown ); return INVALID_POLICY; } //printf("%s, %d\n", __FUNCTION__, __LINE__); retCode += FreeListInit( &tp->jobFreeList, sizeof( ThreadPoolJob ), JOBFREELISTSIZE ); assert( retCode == 0 ); StatsInit( &tp->stats ); retCode += ListInit( &tp->highJobQ, CmpThreadPoolJob, NULL ); assert( retCode == 0 ); retCode += ListInit( &tp->medJobQ, CmpThreadPoolJob, NULL ); assert( retCode == 0 ); retCode += ListInit( &tp->lowJobQ, CmpThreadPoolJob, NULL ); assert( retCode == 0 ); //printf("%s, %d, retcode is %d\n", __FUNCTION__, __LINE__, retCode); if( retCode != 0 ) { retCode = EAGAIN; //printf("%s, %d\n", __FUNCTION__, __LINE__); } else { //printf("%s, %d\n", __FUNCTION__, __LINE__); tp->persistentJob = NULL; tp->lastJobId = 0; tp->shutdown = 0; tp->totalThreads = 0; tp->persistentThreads = 0; //printf("%s, %d\n", __FUNCTION__, __LINE__); for( i = 0; i < tp->attr.minThreads; ++i ) { if( ( retCode = CreateWorker( tp ) ) != 0 ) { //printf("%s, %d\n", __FUNCTION__, __LINE__); break; } } } //printf("%s, %d\n", __FUNCTION__, __LINE__); ithread_mutex_unlock( &tp->mutex ); if( retCode != 0 ) { // clean up if the min threads could not be created ThreadPoolShutdown( tp ); } //printf("%s, %d\n", __FUNCTION__, __LINE__); return retCode; }