Skip to content

Commit

Permalink
Merge pull request #316 from stlab/develop
Browse files Browse the repository at this point in the history
Merge develop into master for 1.5.3
  • Loading branch information
FelixPetriconi authored Sep 16, 2020
2 parents 2e411dd + 013d598 commit e91c220
Show file tree
Hide file tree
Showing 20 changed files with 2,405 additions and 135 deletions.
4 changes: 0 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand Down
9 changes: 9 additions & 0 deletions .hyde-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hyde-src-root": "stlab",
"hyde-yaml-dir": "../stlab.github.io/libraries",
"clang_flags": [
"-std=c++17",
"-I.",
"-Wno-everything"
]
}
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v1.5.3 - 2020 - September 16
- Fixed issues
- [#312](https://github.com/stlab/libraries/issues/312): default_executor implementation for Windows has a memory leak
- [#305](https://github.com/stlab/libraries/issues/305) stlab/concurrency/future.hpp won't compile with C++20
- [#303](https://github.com/stlab/libraries/issues/) range based stlab::when_any data race

- Enhancement
- Adding Forest container and algorithms

## v1.5.2 - 2020 - February 05
- Fixed issues
- [#292](https://github.com/stlab/libraries/issues/292): What happened to our mutable lambdas?
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else()
set( subproject OFF )
endif()

project( stlab VERSION 1.5.2 LANGUAGES CXX )
project( stlab VERSION 1.5.3 LANGUAGES CXX )

include( CTest )
include( CMakeDependentOption )
Expand Down
19 changes: 19 additions & 0 deletions generate_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# The intent of this script is to generate the documentation shell that will eventually be migrated
# to stlab.github.io. This script assumes `stlab/` and `stlab.github.io/` are sibling repositories.

pushd $(dirname $0) > /dev/null

XCODE_TOOLCHAIN=$(xcode-select -p)

# They moved it _again_! *shakes fist*
XCODE_11_5_CPP_DIR=${XCODE_TOOLCHAIN}/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1

# echo ${XCODE_11_5_CPP_DIR}

HYDE_ARGS="--hyde-update --access-filter-public --namespace-blacklist=detail,unsafe --use-system-clang"

hyde ${HYDE_ARGS} stlab/forest.hpp -- -I${XCODE_11_5_CPP_DIR}

popd > /dev/null
97 changes: 97 additions & 0 deletions stlab/algorithm/reverse.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright 2013 Adobe
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
/*************************************************************************************************/

#ifndef STLAB_ALGORITHM_REVERSE_HPP
#define STLAB_ALGORITHM_REVERSE_HPP

#include <algorithm>
#include <utility>

#include <stlab/iterator/set_next.hpp>

/*************************************************************************************************/

namespace stlab {

/*************************************************************************************************/

namespace unsafe {

/*************************************************************************************************/

template <typename I> // I models NodeIterator
I reverse_append(I first, I last, I result) {
while (first != last) {
I prior(first);
++first;
stlab::unsafe::set_next(prior, result);
result = prior;
}
return result;
}

template <typename R, // R models NodeRange
typename I> // I models NodeIterator
inline I reverse_append(R& range, I result) {
return stlab::unsafe::reverse_append(std::begin(range), std::end(range), result);
}

template <typename I> // I models NodeIterator
inline I reverse_nodes(I first, I last) {
return stlab::unsafe::reverse_append(first, last, last);
}

template <typename R> // R models NodeRange
inline typename R::iterator reverse_nodes(R& range) {
return stlab::unsafe::reverse_nodes(std::begin(range), std::end(range));
}

/*************************************************************************************************/

} // namspace unsafe

/*************************************************************************************************/

template <class BidirectionalRange>
inline void reverse(BidirectionalRange& range) {
std::reverse(std::begin(range), std::end(range));
}

template <class BidirectionalRange, class OutputIterator>
inline void reverse_copy(BidirectionalRange& range, OutputIterator result) {
std::reverse_copy(std::begin(range), std::end(range), result);
}

template <class BidirectionalRange, class OutputIterator>
inline void reverse_copy(const BidirectionalRange& range, OutputIterator result) {
std::reverse_copy(std::begin(range), std::end(range), result);
}

/*************************************************************************************************/

template <typename I> // I models BidirectionalIterator
std::pair<I, I> reverse_until(I f, I m, I l) {
while (f != m && m != l) {
--l;

std::iter_swap(f, l);

++f;
}

return std::pair<I, I>(f, l);
}

/*************************************************************************************************/

} // namespace stlab

/*************************************************************************************************/

#endif // STLAB_ALGORITHM_REVERSE_HPP

/*************************************************************************************************/
2 changes: 1 addition & 1 deletion stlab/concurrency/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#elif __cplusplus == 201703L
#define STLAB_CPP_VERSION_PRIVATE() 17
#else
#warning Unknown version of C+; assuming C++20.
//#warning Unknown version of C+; assuming C++20.
#define STLAB_CPP_VERSION_PRIVATE() 20
#endif
#endif
Expand Down
16 changes: 13 additions & 3 deletions stlab/concurrency/default_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,26 @@ class task_system {
template <typename F>
static void CALLBACK callback_impl(PTP_CALLBACK_INSTANCE /*instance*/,
PVOID parameter,
PTP_WORK /*Work*/) {
PTP_WORK work) {
std::unique_ptr<F> f(static_cast<F*>(parameter));
(*f)();
CloseThreadpoolWork(work);
}
};

/**************************************************************************************************/

#elif STLAB_TASK_SYSTEM(PORTABLE)

inline auto queue_size() {
#ifdef STLAB_UNIT_TEST
// The test cannot run with less than two cores
return std::max(2u, std::thread::hardware_concurrency());
#else
return std::thread::hardware_concurrency();
#endif
}

class notification_queue {
using lock_t = std::unique_lock<std::mutex>;
std::deque<task<void()>> _q;
Expand Down Expand Up @@ -295,9 +305,9 @@ class notification_queue {
class priority_task_system {
using lock_t = std::unique_lock<std::mutex>;

const unsigned _count{std::thread::hardware_concurrency()};
const unsigned _count{queue_size()};
// The 64 for spinning over the queues is a value of current experience.
const unsigned _spin{std::thread::hardware_concurrency()<64? 64 : std::thread::hardware_concurrency()};
const unsigned _spin{queue_size()<64? 64 : queue_size()};

struct thread_context
{
Expand Down
Loading

0 comments on commit e91c220

Please sign in to comment.