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

Make a consistent TimelineItem cancellation scheme. #18

Closed
sansumbrella opened this issue Nov 26, 2014 · 5 comments
Closed

Make a consistent TimelineItem cancellation scheme. #18

sansumbrella opened this issue Nov 26, 2014 · 5 comments

Comments

@sansumbrella
Copy link
Owner

Similar to what we have now for Cues. On destruction, associated TimelineItem will be considered invalid/canceled. Could use to make raw pointer animations potentially safe. Auto-wire scope to Output's lifetime when given a ch::Output type.

Any way to bring along the source with an Output on std::move, though? Or do we still need the pointer back to the Connection?

Names:
CancellationControlRef
ConnectionControlRef
TImelineItemControlRef

@sansumbrella
Copy link
Owner Author

On moving Output, maybe something like:

Output( Output &&rhs )
{
  _control = rhs._control;
  if( _control.valid() ) {
    _connection = rhs._connection;
    _connection->updatePtr( this );
  }
}

This seems to skip a bit of the song and dance we have now around the connection rewiring. Does introduce an extra (shared) pointer to the Output, but that's probably not a big deal as it's not a copyable object.

@sansumbrella
Copy link
Owner Author

Once invalidated, forever invalidated Control bit. Connections and Controls will share ptrs to this bit, enabling them to check its status and cancel from either side without knowing about each other.

class ControlBit {
public:
  bool valid() const { return _active; }
  void cancel() { _active = false; }
private: 
  bool _active = true;
};

@sansumbrella
Copy link
Owner Author

Performance degrades a little having a shared_ptr added to every TimelineItem. Will probably revisit this later.

Lazily instantiating the shared_ptr and inverting the control improves performance. TimelineItem::cancelled() is now a non-virtual member method.

@sansumbrella
Copy link
Owner Author

Implemented in unified_cancel branch

@sansumbrella
Copy link
Owner Author

Fixed by #20

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

No branches or pull requests

1 participant