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

Add lcos::local::one_element_channel #2631

Merged
merged 5 commits into from May 26, 2017
Merged

Add lcos::local::one_element_channel #2631

merged 5 commits into from May 26, 2017

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented May 15, 2017

  • refactored local channel implementation
  • channel::set is now optionally asynchronous
  • adding asynchronous iterator support to channel

- adapt specializations of coroutine_traits to latest changes
- properly propagate exceptions through co_await
- flyby: fix co_await future<future<T>>
- flyby: change return to co_return where appropriate
- refactored local channel implementation
- channel::set is now optionally asynchronous
- adding asynchronous iterator support to channel
{
if (push_active_)
{
// error!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return an exceptional future here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that was the plan ;)

{
if (pop_active_)
{
// error!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return an exceptional future here?


void cancel(boost::exception_ptr const& e)
{
if (pop_active_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done inside the lock as well to avoid races.

Copy link
Member Author

@hkaiser hkaiser May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called while the lock is being held. I'll make it explicit.


private:
friend class channel_iterator<T>;
friend class receive_channel<T>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need to be friends with itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, copy&paste error.

{}
receive_channel(one_element_channel<void> const& c)
: base_type(c.get_channel_impl())
{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't a constructor taking a channel_base const& be enough?

: base_type(c.get_channel_impl())
{}
send_channel(one_element_channel<T> const& c)
: base_type(c.get_channel_impl())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't a constructor taking a channel_base const& be enough?

{}
receive_channel(one_element_channel<T> const& c)
: base_type(c.get_channel_impl())
{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't a constructor taking a channel_base const& be enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No for two reasons:

  • in that case a receive_channel would become constructible from a send_channel, for instance
  • all channel classes are non-publicly derived (using protected derivation) from channel_base

@sithhell
Copy link
Member

sithhell commented May 18, 2017 via email

@hkaiser
Copy link
Member Author

hkaiser commented May 18, 2017

Hmm, I'm not a big fan of that

Of what? Could you elaborate, please?

@sithhell
Copy link
Member

Hmm, I'm not a big fan of that

Of what? Could you elaborate, please?

That we essentially have to list all channel implementations in the ctor of receive_channel and send_channel. Guess it is not something blocking right now, still a little nuisance,

@hkaiser
Copy link
Member Author

hkaiser commented May 23, 2017

That we essentially have to list all channel implementations in the ctor of receive_channel and send_channel . Guess it is not something blocking right now, still a little nuisance,

I don't have a better solution. Besides, being explicit is always better than relying on implicit conversions.

@hkaiser hkaiser merged commit 847d58f into master May 26, 2017
@hkaiser hkaiser deleted the channel_one_element branch May 26, 2017 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants