Skip to content
Open
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
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ if(STDEXEC_BUILD_TESTS)
endif()

# These headers are Linux-only.
if(WIN32)
if(NOT LINUX)
set_source_files_properties(
include/exec/linux/io_uring_context.hpp
include/exec/linux/memory_mapped_region.hpp
Expand All @@ -306,6 +306,13 @@ if(STDEXEC_BUILD_TESTS)
include/exec/linux/detail/safe_file_descriptor.hpp
PROPERTIES SKIP_LINTING ON)
endif()

# These headers are macOS-only.
if(NOT APPLE)
set_source_files_properties(
include/exec/libdispatch_queue.hpp
PROPERTIES SKIP_LINTING ON)
endif()
endif()

# Declare the public include directories
Expand Down Expand Up @@ -349,6 +356,10 @@ if(NOT STDEXEC_NAMESPACE STREQUAL "stdexec")
STDEXEC_NAMESPACE=${STDEXEC_NAMESPACE})
endif()

if (NOT STDEXEC_BUILD_PARALLEL_SCHEDULER)
target_compile_definitions(stdexec INTERFACE STDEXEC_PARALLEL_SCHEDULER_HEADER_ONLY)
endif()

option(STDEXEC_ENABLE_EXTRA_TYPE_CHECKING
"Enable extra type checking that is costly at compile-time" OFF)
if(STDEXEC_ENABLE_EXTRA_TYPE_CHECKING)
Expand Down Expand Up @@ -580,13 +591,16 @@ if(STDEXEC_BUILD_PARALLEL_SCHEDULER)
/Zc:preprocessor /Zc:externConstexpr>)
target_link_libraries(parallel_scheduler PUBLIC stdexec)

add_library(STDEXEC::parallel_scheduler ALIAS parallel_scheduler)
add_library(system_context ALIAS parallel_scheduler)
add_library(STDEXEC::system_context ALIAS parallel_scheduler)

set(stdexec_export_targets ${stdexec_export_targets} parallel_scheduler)
else()
add_library(parallel_scheduler INTERFACE)
target_link_libraries(parallel_scheduler INTERFACE stdexec)
endif()

add_library(STDEXEC::parallel_scheduler ALIAS parallel_scheduler)
add_library(system_context ALIAS parallel_scheduler)
add_library(STDEXEC::system_context ALIAS parallel_scheduler)

option(STDEXEC_ENABLE_IO_URING
"Enable the use of the io_uring scheduler on Linux" OFF)

Expand Down
18 changes: 9 additions & 9 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function(def_example example)
# emitted from stdlib
# headers, why?
$<$<CXX_COMPILER_ID:Clang>:-Wno-gnu-line-marker>)
target_compile_definitions(${target} PRIVATE
$<$<PLATFORM_ID:Windows>:NOMINMAX>
)
target_link_libraries(
${target}
PRIVATE STDEXEC::stdexec stdexec_executable_flags stdexec_example_settings
Expand Down Expand Up @@ -86,15 +89,8 @@ foreach(example ${stdexec_examples})
def_example(${example})
endforeach()

if(STDEXEC_BUILD_PARALLEL_SCHEDULER)
target_link_libraries(example.hello_world PUBLIC STDEXEC::parallel_scheduler)
target_link_libraries(example.sudoku PRIVATE STDEXEC::parallel_scheduler)
else()
target_compile_definitions(example.hello_world
PRIVATE STDEXEC_PARALLEL_SCHEDULER_HEADER_ONLY)
target_compile_definitions(example.sudoku
PRIVATE STDEXEC_PARALLEL_SCHEDULER_HEADER_ONLY)
endif()
target_link_libraries(example.hello_world PUBLIC STDEXEC::parallel_scheduler)
target_link_libraries(example.sudoku PRIVATE STDEXEC::parallel_scheduler)

if(STDEXEC_ENABLE_CUDA)
add_subdirectory(nvexec)
Expand Down Expand Up @@ -132,4 +128,8 @@ if(STDEXEC_ENABLE_ASIO)
example.benchmark.asio_thread_pool
PRIVATE stdexec_example_settings STDEXEC::asioexec
$<TARGET_NAME_IF_EXISTS:TBB::tbb>)
target_compile_definitions(
example.benchmark.asio_thread_pool
PRIVATE $<$<PLATFORM_ID:Windows>:NOMINMAX>
)
endif()
3 changes: 2 additions & 1 deletion examples/benchmark/asio_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "./common.hpp"
#include <exec/asio/asio_thread_pool.hpp>

#include "./common.hpp"
#include <exec/start_detached.hpp>

struct RunThread
Expand Down
2 changes: 1 addition & 1 deletion examples/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ auto main() -> int

{
sender auto nest = scope.nest(begin);
auto op = connect(std::move(nest), noop_receiver{});
auto op = stdexec::connect(std::move(nest), noop_receiver{});
(void) op;
}
sync_wait(scope.on_empty());
Expand Down
66 changes: 43 additions & 23 deletions include/exec/libdispatch_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,53 @@

#pragma once

#if __has_include(<dispatch/dispatch.h>)
#include "../stdexec/__detail/__config.hpp"

# include <stdexec/execution.hpp>

# if STDEXEC_USE_MODULES() && !defined(STDEXEC_IN_MODULE_PURVIEW)
#if STDEXEC_USE_MODULES() && !defined(STDEXEC_IN_MODULE_PURVIEW)
import std;
import stdexec;
# else
#else
# include "../stdexec/__detail/__bulk.hpp"
# include "../stdexec/__detail/__domain.hpp"
# include "../stdexec/__detail/__env.hpp"
# include "../stdexec/__detail/__execution_fwd.hpp"
# include "../stdexec/__detail/__execution_legacy.hpp" // IWYU pragma: keep
# include "../stdexec/__detail/__operation_states.hpp"
# include "../stdexec/__detail/__receivers.hpp"
# include "../stdexec/__detail/__schedulers.hpp"
# include "../stdexec/__detail/__stop_token.hpp"
# include "../stdexec/__detail/__transform_sender.hpp"

# if !STDEXEC_USE_MODULES()
# include <algorithm>
# include <atomic>
# include <concepts>
# include <cstddef>
# include <cstdint>
# include <exception>
# include <tuple>
# include <type_traits>
# include <utility>
# include <variant>
# include <vector>
# endif
#endif

#include "completion_signatures.hpp"
#include "sender_for.hpp"

#if !defined(STDEXEC_IN_MODULE_PURVIEW)
// TODO: This is needed for libdispatch to compile with GCC. Need to look for
// workaround.
# ifndef __has_feature
# define __has_feature(x) false
# endif
# ifndef __has_extension
# define __has_extension(x) false
# endif

# include "completion_signatures.hpp"
# include "sender_for.hpp"

# if !STDEXEC_USE_MODULES()
# include <dispatch/dispatch.h>
# include <utility>
# include <vector>
# endif
# ifndef __has_feature
# define __has_feature(x) false
# endif
# ifndef __has_extension
# define __has_extension(x) false
# endif

# include <dispatch/dispatch.h>
#endif

namespace experimental::execution
{
Expand Down Expand Up @@ -597,6 +620,3 @@ namespace experimental::execution
} // namespace experimental::execution

namespace exec = experimental::execution;

# endif // !STDEXEC_USE_MODULES() || defined(STDEXEC_IN_MODULE_PURVIEW)
#endif // __has_include(<dispatch/dispatch.h>)
9 changes: 9 additions & 0 deletions include/exec/trampoline_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ namespace experimental::execution
{
// Exceeded recursion limit.

// GCC may warn that this stores the address of a local operation
// state into thread-local storage. That is a false positive: an
// enclosing origin schedule frame owns the state and drains the
// queue before this operation state's lifetime ends.
STDEXEC_PRAGMA_PUSH()
STDEXEC_PRAGMA_IGNORE_GNU("-Wdangling-pointer")

// push this recursive schedule to list tail
__prev_ = std::exchange(__current_state->__tail_, static_cast<__opstate_base*>(this));
if (__prev_ != nullptr)
Expand All @@ -189,6 +196,8 @@ namespace experimental::execution
// was empty
__current_state->__head_ = static_cast<__opstate_base*>(this);
}

STDEXEC_PRAGMA_POP()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ import stdexec;
namespace STDEXEC::parallel_scheduler_replacement
{
//! Get the backend for the parallel scheduler.
//! Users might replace this function.
STDEXEC_MODULE_EXPORT
STDEXEC_ATTRIBUTE(weak)
auto query_parallel_scheduler_backend() -> std::shared_ptr<parallel_scheduler_backend>;

//! The type of a factory that can create `parallel_scheduler_backend`
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ set_target_properties(
target_include_directories(common_test_settings
INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
target_compile_definitions(
common_test_settings INTERFACE STDEXEC_NAMESPACE=std::execution
$<$<PLATFORM_ID:Windows>:NOMINMAX>)
common_test_settings INTERFACE $<$<PLATFORM_ID:Windows>:NOMINMAX>)
target_compile_options(
common_test_settings
INTERFACE
Expand Down Expand Up @@ -163,7 +162,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
endif()
target_link_libraries(
test.stdexec
PUBLIC STDEXEC::stdexec stdexec_executable_flags Catch2::Catch2WithMain
PUBLIC STDEXEC::stdexec STDEXEC::parallel_scheduler stdexec_executable_flags
Catch2::Catch2WithMain
PRIVATE common_test_settings)

if(STDEXEC_BUILD_PARALLEL_SCHEDULER)
Expand Down
2 changes: 1 addition & 1 deletion test/exec/asio/test_asio_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <exec/asio/asio_thread_pool.hpp>

#include <catch2/catch_all.hpp>

#include <stdexec/execution.hpp>

#include <exec/asio/asio_thread_pool.hpp>
#include <exec/asio/use_sender.hpp>
#include <exec/inline_scheduler.hpp>
#include <exec/static_thread_pool.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/exec/test_materialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ namespace
set_equivalent<completion_signatures_of_t<decltype(sndr)>,
completion_signatures<set_value_t(set_error_t, noncopyable_error&)>>);

auto op = connect(std::move(sndr), error_receiver{&error, &called});
auto op = ex::connect(std::move(sndr), error_receiver{&error, &called});
start(op);
CHECK(called);
}
Expand Down
2 changes: 1 addition & 1 deletion test/run_loop_finish_repro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <thread>

namespace ex = STDEXEC_NAMESPACE;
namespace ex = STDEXEC;

void run_once()
{
Expand Down
3 changes: 2 additions & 1 deletion test/stdexec/schedulers/test_parallel_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/
#include <catch2/catch_all.hpp>

#define STDEXEC_PARALLEL_SCHEDULER_HEADER_ONLY 1
#include <stdexec/execution.hpp>

#include <stdexec/__detail/__parallel_scheduler_default_impl.hpp>

#include <exec/async_scope.hpp>
#include <exec/inline_scheduler.hpp>
#include <exec/static_thread_pool.hpp>
Expand Down