当前位置: 首页 > news >正文

网站seo优缺点网站开发有哪些风险

网站seo优缺点,网站开发有哪些风险,沈阳模板建站哪家好,wordpress 自动博客FRunnable和FRunnableThread方法对于大多数问题来说无疑是一个可行的解决方案。 但是#xff0c;在创建许多任务时#xff0c;您可能会达到CPU可以处理的并发上限#xff0c;此时并发线程实际上会在争用CPU时间时相互阻碍。 然后可能值得查看FQueuedThreadPool以限制任务可用…FRunnable和FRunnableThread方法对于大多数问题来说无疑是一个可行的解决方案。 但是在创建许多任务时您可能会达到CPU可以处理的并发上限此时并发线程实际上会在争用CPU时间时相互阻碍。 然后可能值得查看FQueuedThreadPool以限制任务可用的线程数。 虚幻引擎4还提供了全局GThreadPool 但是此线程池仅设置为单个线程UE4.14.3。 它似乎只是为了在另一个核心上运行并发任务。 下面的代码是什么 创建一个线程来计算前50,000个素数将增量完成数据发送回游戏线程具有静态访问器用于启动关闭和查找线程是否已完成。 静态函数 您将在下面的代码中注意到我使用静态函数轻松启动新线程如果我需要匆忙关闭线程例如播放器退出我也可以使用GameThread中的静态Shutdown函数游戏 性能 我首先使用任务图系统计算前50,000个素数并创建50,000个任务每个素数找1个。 在本教程中看到的代码中我创建了一个专用线程来计算前50,000个素数 性能优势是非凡的 我的fps在下面的代码中为这个线程的整个运行保持稳定90我选择的最大fps。 而对于任务图系统当我接近50,000时fps下降了最多40。 对于较大的任务请务必尝试实际的多线程 .H //~~~~~ Multi Threading ~~~ class FPrimeNumberWorker : public FRunnable { /** Singleton instance, can access the thread any time via static accessor, if it is active! */static FPrimeNumberWorker* Runnable;/** Thread to run the worker FRunnable on */FRunnableThread* Thread;/** The Data Ptr */TArrayuint32* PrimeNumbers;/** The PC */AVictoryGamePlayerController* ThePC;/** Stop this thread? Uses Thread Safe Counter */FThreadSafeCounter StopTaskCounter;//The actual finding of prime numbersint32 FindNextPrimeNumber();private:int32 PrimesFoundCount; public:int32 TotalPrimesToFind;//Done?bool IsFinished() const{return PrimesFoundCount TotalPrimesToFind;}//~~~ Thread Core Functions ~~~//Constructor / DestructorFPrimeNumberWorker(TArrayuint32 TheArray, const int32 IN_PrimesToFindPerTick, AVictoryGamePlayerController* IN_PC);virtual ~FPrimeNumberWorker();// Begin FRunnable interface.virtual bool Init();virtual uint32 Run();virtual void Stop();// End FRunnable interface/** Makes sure this thread has stopped properly */void EnsureCompletion();//~~~ Starting and Stopping Thread ~~~/* Start the thread and the worker from static (easy access)! This code ensures only 1 Prime Number thread will be able to run at a time. This function returns a handle to the newly started instance.*/static FPrimeNumberWorker* JoyInit(TArrayuint32 TheArray, const int32 IN_TotalPrimesToFind, AVictoryGamePlayerController* IN_PC);/** Shuts down the thread. Static so it can easily be called from outside the thread context */static void Shutdown();static bool IsThreadFinished();};.CPP //*********************************************************** //Thread Worker Starts as NULL, prior to being instanced // This line is essential! Compiler error without it FPrimeNumberWorker* FPrimeNumberWorker::Runnable NULL; //***********************************************************FPrimeNumberWorker::FPrimeNumberWorker(TArrayuint32 TheArray, const int32 IN_TotalPrimesToFind, AVictoryGamePlayerController* IN_PC): ThePC(IN_PC), TotalPrimesToFind(IN_TotalPrimesToFind), StopTaskCounter(0), PrimesFoundCount(0) {//Link to where data should be storedPrimeNumbers TheArray;Thread FRunnableThread::Create(this, TEXT(FPrimeNumberWorker), 0, TPri_BelowNormal); //windows default 8mb for thread, could specify more }FPrimeNumberWorker::~FPrimeNumberWorker() {delete Thread;Thread NULL; }//Init bool FPrimeNumberWorker::Init() {//Init the Data PrimeNumbers-Empty();PrimeNumbers-Add(2);PrimeNumbers-Add(3);if(ThePC) {ThePC-ClientMessage(**********************************);ThePC-ClientMessage(Prime Number Thread Started!);ThePC-ClientMessage(**********************************);}return true; }//Run uint32 FPrimeNumberWorker::Run() {//Initial wait before startingFPlatformProcess::Sleep(0.03);//While not told to stop this thread // and not yet finished finding Prime Numberswhile (StopTaskCounter.GetValue() 0 ! IsFinished()){PrimeNumbers-Add(FindNextPrimeNumber());PrimesFoundCount;//***************************************//Show Incremental Results in Main Game Thread!// Please note you should not create, destroy, or modify UObjects here.// Do those sort of things after all thread are completed.// All calcs for making stuff can be done in the threads// But the actual making/modifying of the UObjects should be done in main game thread.ThePC-ClientMessage(FString::FromInt(PrimeNumbers-Last()));//***************************************//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//prevent thread from using too many resources//FPlatformProcess::Sleep(0.01);//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}//Run FPrimeNumberWorker::Shutdown() from the timer in Game Thread that is watching//to see when FPrimeNumberWorker::IsThreadFinished()return 0; }//stop void FPrimeNumberWorker::Stop() {StopTaskCounter.Increment(); }FPrimeNumberWorker* FPrimeNumberWorker::JoyInit(TArrayuint32 TheArray, const int32 IN_TotalPrimesToFind, AVictoryGamePlayerController* IN_PC) {//Create new instance of thread if it does not exist// and the platform supports multi threading!if (!Runnable FPlatformProcess::SupportsMultithreading()){Runnable new FPrimeNumberWorker(TheArray,IN_TotalPrimesToFind,IN_PC); }return Runnable; }void FPrimeNumberWorker::EnsureCompletion() {Stop();Thread-WaitForCompletion(); }void FPrimeNumberWorker::Shutdown() {if (Runnable){Runnable-EnsureCompletion();delete Runnable;Runnable NULL;} }bool FPrimeNumberWorker::IsThreadFinished() {if(Runnable) return Runnable-IsFinished();return true; } int32 FPrimeNumberWorker::FindNextPrimeNumber() {//Last known prime number 1int32 TestPrime PrimeNumbers-Last();bool NumIsPrime false;while( ! NumIsPrime){NumIsPrime true;//Try Next NumberTestPrime;//Modulus from 2 to current number - 1 for(int32 b 2; b TestPrime; b){//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//prevent thread from using too many resources//FPlatformProcess::Sleep(0.01);//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~if(TestPrime % b 0) {NumIsPrime false;break;//~~~}}}//Success!return TestPrime; }Starting the thread //In the .h for the player controller // this is the actual data TArrayuint32 PrimeNumbers;//player controller .cpp //Multi-threading, returns handle that could be cached. // use static function FPrimeNumberWorker::Shutdown() if necessary FPrimeNumberWorker::JoyInit(PrimeNumbers, 50000, this);线程管理 您应该查看“FRunnable”的代码库以查看多线程和锁定/解锁保护的扩展用途。 我用了一个简单的例子来帮助你入门但是多线程时需要考虑很多:) 使用Sleep进行线程管理 你应该考虑使用 FPlatformProcess :: Sleep 秒 ;防止1个线程占用太多系统资源:) 什么不该做 不要尝试从其他线程修改创建或删除UObject 您可以准备所有数据/进行所有计算但只有游戏线程应该实际产生/修改/删除UObjects / AActors。 不要尝试在游戏线程之外使用TimerManager :) 不要试图绘制调试行/点等因为它可能会崩溃即DrawDebugLine等... 通知自4.11起 如果要使用计时器删除和修改变量请使用它 #include “Async.h” ...AsyncTask ENamedThreads :: GameThread [] {//这里在游戏线程上执行的代码};GameThread中的计时器功能 您可以在游戏线程中运行计时器功能以定期检查您创建的其他线程收集的数据。 如何支持单线程平台 如果您的代码绝对必须在HTML5等单线程环境中运行那么请查看 AsyncIOSystemBase.h struct CORE_API FAsyncIOSystemBasepublic FIOSystemFRunnableFSingleThreadRunnableRunnable可以扩展SingleThreadRunnable并为单线程情况下的FRunnable钩子返回自己 /*** Gets single thread interface pointer used for ticking this runnable when multi-threading is disabled.* If the interface is not implemented, this runnable will not be ticked when FPlatformProcess::SupportsMultithreading() is false.** return Pointer to the single thread interface or nullptr if not implemented.*/ virtual class FSingleThreadRunnable* GetSingleThreadInterface( ) {return nullptr; }
http://www.yutouwan.com/news/172884/

相关文章:

  • 中国建设部官方网站鲁班奖公司网站程序
  • 营销网站域名设计网上智慧团建网站
  • 天猫网站做链接怎么做深圳网站建设哪家好
  • 如何做淘宝联盟网站的推广seo网页的基础知识
  • 网站开发工程师题南城网站建设公司策划
  • 自己做的网站上出现乱码怎么修改建设网站怎样赚钱
  • 聊城手机网站建设多少钱一般网站宽度
  • 免费自动建站国内网站免费服务器
  • 做网站能用微软住房和建设部执业资格注册中心网站
  • 小型网站建设公司wordpress 仿小米主题下载
  • 网站建设人员需求分析有哪些专门做减肥内容的网站
  • 天津网站建设 Wordpress毕设做网站些什么比较简单
  • 台州知名的网站建设outlook企业邮箱怎么申请
  • 星月教你做网站回顾文档windows 2003建设网站
  • 公司门户网站怎么做协会网站建设方案
  • 网站推广哪个平台好手机版文章网站源码
  • 无锡市住房和城乡建设局网站县级网站建设
  • 三网合一网站怎么做一个新手怎么做电商运营
  • 南通网站建设招聘微信网站链接网站建设
  • 合肥建设集团信息网站徐州睢宁建设网站
  • 网站一跳率惠州模板做网站
  • .net网站项目有哪些怎么制作网站记事本
  • 网站快速优化排名排名wordpress图集功能
  • 艺术设计专业灵感推荐网站成都网站网站建设
  • 网站建设一条龙服务网站建设中的注册和登录页面
  • 南京企业网站开发wordpress主题安装路径
  • 动态表情包在线制作网站虚拟机wordpress安装教程
  • 网站流量分析工具国内十大软件培训机构
  • 福建省建设资格管理中心网站网站建设门户
  • 如何用dreamer做网站有做学历在网站能查的到的