Skip to content

Instantly share code, notes, and snippets.

@mockturtl
Last active August 29, 2015 14:09
Show Gist options
  • Save mockturtl/97c0e692034888524f74 to your computer and use it in GitHub Desktop.
Save mockturtl/97c0e692034888524f74 to your computer and use it in GitHub Desktop.

Revisions

  1. mockturtl revised this gist Nov 14, 2014. 1 changed file with 20 additions and 18 deletions.
    38 changes: 20 additions & 18 deletions momdad.dart
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,31 @@
    import 'dart:async';

    Stopwatch mom = new Stopwatch();
    Stopwatch dad = new Stopwatch();
    Duration dur = new Duration(seconds: 1);
    Duration dur = new Duration(milliseconds: 400);

    mymom() async {
    mom.start();
    while(true){
    if(mom.elapsed > dur){
    print('mom cooks'); //obviously
    mom.reset();
    }
    Future mymom() async {
    if(mom.elapsed > dur){
    print('mom cooks');
    mom.reset();
    }
    mymom();
    }

    mydad() async {
    dad.start();
    while(true){
    if(dad.elapsed > dur){
    print('dad works');
    dad.reset();
    }
    }
    Future mydad() async {
    if(dad.elapsed > dur){
    print('dad works');
    dad.reset();
    }
    mydad();
    }

    main() {
    mom.start();
    dad.start();

    mymom();
    mydad();
    print('also true');
    }

    print('end of main');
    }
  2. mockturtl created this gist Nov 14, 2014.
    29 changes: 29 additions & 0 deletions momdad.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    Stopwatch mom = new Stopwatch();
    Stopwatch dad = new Stopwatch();
    Duration dur = new Duration(seconds: 1);

    mymom() async {
    mom.start();
    while(true){
    if(mom.elapsed > dur){
    print('mom cooks'); //obviously
    mom.reset();
    }
    }
    }

    mydad() async {
    dad.start();
    while(true){
    if(dad.elapsed > dur){
    print('dad works');
    dad.reset();
    }
    }
    }

    main() {
    mymom();
    mydad();
    print('also true');
    }