Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlib::optional #2815

Merged
merged 28 commits into from
Jul 8, 2023
Merged

dlib::optional #2815

merged 28 commits into from
Jul 8, 2023

Conversation

pfeatherstone
Copy link
Contributor

@pfeatherstone pfeatherstone commented Jun 25, 2023

This is work in progress.
This is inspired by Sy Brand's tl::optional repo and https://github.com/bitwizeshift/BackportCpp.git
I've tried a few different ways of doing things. For example, i didn't like using union but it turns out you can't use aligned_storage if you want things to be constexpr and direct initialization to work.
I have to say, this is an education in C++ initialization. It's laughable how complicated an object that is either active or None can be. C++ is so messed up. And yet, I love it

@pfeatherstone pfeatherstone marked this pull request as ready for review June 27, 2023 21:16
@pfeatherstone
Copy link
Contributor Author

It's ready. I think it's a good addition

@davisking
Copy link
Owner

Sweet, I'll look in a bit :D

@pfeatherstone
Copy link
Contributor Author

@davisking Have you had a chance to look at this ?

@davisking
Copy link
Owner

Sorry, not yet. Haven't forgotten though 😅

@pfeatherstone
Copy link
Contributor Author

pfeatherstone commented Jul 6, 2023

I quite like the .then() pattern, i.e. continuations. I wonder how hard it would be to enhance dlib::thread_pool to support continuations on tasks and combine them using free functions like when_all(), when_one(), when_seq(), or alternatively using &&, ||, >>. Then use another function wait() to wait for the task graph to complete.

@davisking
Copy link
Owner

I quite like the .then() pattern, i.e. continuations. I wonder how hard it would be to enhance dlib::thread_pool to support continuations on tasks and combine them using free functions like when_all(), when_one(), when_seq(), or alternatively using &&, ||, >>. Then use another function wait() to wait for the task graph to complete.

Yeah, depends on how heavy handed you want the implementation to be. Like if every call to any of these functions spawned a new thread that just waited on the future(s) to be ready that's easy. But something less heavyweight gets tricky fast.

@davisking
Copy link
Owner

davisking commented Jul 8, 2023

This is real nice. I just spent nearly 2 hours reading it all over and trying to find problems but couldn't find any. Thought I saw a bug at one point but was wrong :)

Thanks for the awesome PR.

@davisking davisking merged commit 4e22715 into davisking:master Jul 8, 2023
10 checks passed
@pfeatherstone pfeatherstone deleted the optional branch July 8, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants