~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/barrier.h

  • Committer: Brian Aker
  • Date: 2010-11-18 08:32:27 UTC
  • mto: (1939.1.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1940.
  • Revision ID: brian@tangent.org-20101118083227-3evnnsgw5cwtuv7f
Add additional test for barriers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
    }
90
90
  }
91
91
 
 
92
  void wait(int64_t generation_arg)
 
93
  {
 
94
    boost::mutex::scoped_lock scopedLock(sleeper_mutex);
 
95
    int64_t my_generation= generation;
 
96
 
 
97
    // If the generation is newer  then we just return immediatly
 
98
    if (my_generation > generation_arg)
 
99
      return;
 
100
 
 
101
    if (wait_count)
 
102
    {
 
103
      if (not --current_wait)
 
104
      {
 
105
        generation++;
 
106
        current_wait= wait_count;
 
107
        sleep_threshhold.notify_all();
 
108
 
 
109
        return;
 
110
      }
 
111
 
 
112
    }
 
113
 
 
114
    while (my_generation == generation)
 
115
    {
 
116
      sleep_threshhold.wait(sleeper_mutex);
 
117
    }
 
118
  }
 
119
 
92
120
  int64_t getGeneration() const
93
121
  {
94
122
    return generation;