UE4/5C++多线程插件制作(0.简介)

目录

插件介绍

插件效果

插件使用

English


插件介绍

该插件制作,将从零开始,由一个空白插件一点点的制作,从写一个效果到封装,层层封装插件,简单粗暴的对插件进行了制作:

插件效果

更多的是在cpp中去使用这个插件,而不是在蓝图中,所以对于蓝图接口并没有进行一个精致的制作【有一个蓝图接口,但因为不是专门去制作的,所以这个蓝图接口实际上只能用于简单的异步加载来做一些gameinstance之类的事情,如果有需要,可以自行在里面进行添加相对应的函数。】

插件使用

如何使用这个插件,对此我在MTPLevelSubsystemBPInterface.h的底下做了注释,里面的其实是一个pawn类,只需要将里面的相应函数复制到pawn类就可以知道这是如何使用的了,不过还是简单的进行讲解:

主要的使用是分为几个大类:

自定义线程创建,简单直接创建线程:FThreadAgendyManage ThreadAgendyManage;
自定义线程池,可以往线程池内丢任务,让任务执行:FThreadTaskManageMent ThreadTaskManageMent;
从ue中的线程池内直接取线程执行:FMTPThreadAbandonableManage ThreadAbandonableManage;

协程:FMTPCoroutinesManage CoroutinesManage;

可以设置前置任务的ue线程池:FMTPThreadGraphManage GraphManage;
资源读取:FResourceLoadManage ResourceLoadManage;

使用方法是一样的,先获取他们的管理,然后使用create或者是bind,create是绑定之后直接执行异步,而bind则是创建之后挂起,由你决定使用join还是detach。

English

 How to use this plugin, I'm in MTPLevelSubsystemBPInterface. H under made a comment, it is actually a pawn class, only need to copies inside the corresponding function to pawn class can know how it is used, but is still easy to explain:

Custom thread creation, simply create a thread directly: FThreadAgendyManage ThreadAgendyManage;

To customize the thread pool, you can throw tasks into the thread pool and let the tasks execute: FThreadTaskManageMent ThreadTaskManageMent;

Take directly from ue in the thread pool thread execution: FMTPThreadAbandonableManage ThreadAbandonableManage;

Coroutine: FMTPCoroutinesManage CoroutinesManage;

You can set the ue thread pool for the preceding task: FMTPThreadGraphManage GraphManage;

Resource read :FResourceLoadManage ResourceLoadManage;

The method of using them is the same, first get their management, then use create or bind, create the async directly after binding, and bind is created and suspended, depending on whether you use join or detach.

猜你喜欢

转载自blog.csdn.net/q244645787/article/details/132001284