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

Signal class #350

Merged
merged 10 commits into from
Mar 16, 2015
Merged

Signal class #350

merged 10 commits into from
Mar 16, 2015

Conversation

jslee02
Copy link
Member

@jslee02 jslee02 commented Mar 13, 2015

This pull request introduces the Signal class that provides signal/slot mechanism.

Basic usage:

void foo1() {}
void foo2(int) {}
void foo3(int, float) {}
double foo4() {}
double bar() {}

int main()
{
  Signal<void()> s1;
  Signal<void(int)> s2;
  Signal<void(int, float)> s3;
  Signal<double()> s4;

  Connection c1 = signal1.connect(&foo1);
  Connection c2 = signal2.connect(&foo2);
  Connection c3 = signal3.connect(&foo3);
  Connection c4 = signal4.connect(&foo4);

  s1.raise();  // foo1() called
  s2(10);  // foo2(10) called
  s3(5, 1.5)  // foo3(5, 1.5) called
  double res = s4();  // foo4() called

  c1.disconnect();  

  s1.raise();  // nothing called

  signal4.connect(&bar);

  s4();  // foo4() and bar() called
}

This Signal class is quiet similar to Boost.Signals2 but is light-weight version and faster than Boost.Signals2.

This Signal is not thread safe. It will be considered when we start to make DART thread safe.

@jslee02 jslee02 added this to the Release DART 5.0 milestone Mar 15, 2015
@jslee02
Copy link
Member Author

jslee02 commented Mar 16, 2015

+1

jslee02 added a commit that referenced this pull request Mar 16, 2015
@jslee02 jslee02 merged commit 616913a into master Mar 16, 2015
@jslee02 jslee02 deleted the signal branch March 18, 2015 09:28
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.

1 participant