Skip to content

Commit

Permalink
v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
F-Mu committed Dec 11, 2022
1 parent c2c758f commit 3b080a4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.23)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
project(Vulkan_Thread_Pool)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-autolink")

include_directories(/opt/homebrew/include ./include)
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ https://github.com/blurrypiano/littleVulkanEngine/tree/master

按1~5可以生成执行时间为1~5秒的睡眠任务

同时用来实验C++书籍中的条款

**v2.0**

+ 大重构(感谢学长给的基本架构)
Expand Down Expand Up @@ -46,6 +48,16 @@ https://github.com/blurrypiano/littleVulkanEngine/tree/master

+ 添加了一个极其丑陋的删除粒子动画(甚至算不上粒子)

+ 调整资源结构

**v3.1**

+ 为了去除bind改用lambda(实现条款),改用C++20(C++20 deprecated了glm库某些特性,会报警告)

+ 修改README

+ 调整ParticleComponent的参数,使其效果更佳(但还是很丑陋)

**待实现(可能也不会实现):**

+ 更好的异步执行(Job System)
Expand Down
Binary file modified image/Rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified image/ThreadPool.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added shaders/particle_shader.frag.spv
Binary file not shown.
Binary file added shaders/particle_shader.vert.spv
Binary file not shown.
2 changes: 1 addition & 1 deletion src/function/framework/component/particle_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace crp {

[[nodiscard]] int getLife() const { return life; }

constexpr static int MAX_LIFE = 3;
constexpr static int MAX_LIFE = 8;
private:
int life{MAX_LIFE};
glm::vec4 position;
Expand Down
9 changes: 7 additions & 2 deletions src/resources/systems/task_queue_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "render/render_frame_info.hpp"
#include "function/global/global_context.hpp"
#include "resources/res_type/task.hpp"

namespace crp {
class TaskQueueSystem : public Rectangle {
public:
Expand Down Expand Up @@ -45,8 +46,12 @@ namespace crp {

if (locked)
return std::optional<TaskResult<Fun, Args...>>();

auto t = std::make_shared<task>(std::bind(std::forward<Fun>(fun), std::forward<Args>(args)...));
//条款34:优先选用lambda式,而非std::bin
//此处使用C++20捕获模版不定实参
auto t = std::make_shared<task>(
[fun = std::forward<Fun>(fun), ...args = std::forward<Args>(args)]() -> decltype(auto) {
return fun(args...);
});
auto ret = t->get_future();
{
std::lock_guard<std::mutex> lock(this->taskMut);
Expand Down

0 comments on commit 3b080a4

Please sign in to comment.