Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cppwinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace cppwinrt
{ "brackets", 0, 0 }, // Use angle brackets for #includes (defaults to quotes)
{ "fastabi", 0, 0 }, // Enable support for the Fast ABI
{ "ignore_velocity", 0, 0 }, // Ignore feature staging metadata and always include implementations
{ "synchronous", 0, 0 }, // Instructs cppwinrt to run on a single thread to avoid file system issues in batch builds
};

static void print_usage(writer& w)
Expand Down Expand Up @@ -290,6 +291,7 @@ Where <spec> is one or more of:

w.flush_to_console();
task_group group;
group.synchronous(args.exists("synchronous"));
writer ixx;
write_preamble(ixx);
ixx.write("module;\n");
Expand Down
19 changes: 14 additions & 5 deletions cppwinrt/task_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ namespace cppwinrt
}
}

void synchronous(bool synchronous) noexcept
{
m_synchronous = synchronous;
}

template <typename T>
void add(T&& callback)
{
#if defined(_DEBUG)
callback();
#else
m_tasks.push_back(std::async(std::forward<T>(callback)));
#endif
if (m_synchronous)
{
callback();
}
else
{
m_tasks.push_back(std::async(std::forward<T>(callback)));
}
}

void get()
Expand All @@ -45,5 +53,6 @@ namespace cppwinrt
private:

std::vector<std::future<void>> m_tasks;
bool m_synchronous{};
};
}