GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
reply_increment_counter.cpp
1 /**
2  * Copyright (c) 2009 Carnegie Mellon University.
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an "AS
13  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14  * express or implied. See the License for the specific language
15  * governing permissions and limitations under the License.
16  *
17  * For more about this software visit:
18  *
19  * http://www.graphlab.ml.cmu.edu
20  *
21  */
22 
23 
24 #include <string>
25 #include <graphlab/rpc/dc.hpp>
26 #include <graphlab/rpc/reply_increment_counter.hpp>
27 
28 namespace graphlab {
29 
30 void reply_increment_counter(distributed_control &dc, procid_t src,
31  size_t ptr, dc_impl::blob ret) {
32  dc_impl::reply_ret_type *a = reinterpret_cast<dc_impl::reply_ret_type*>(ptr);
33  a->mut.lock();
34  a->val = ret;
35  size_t retval = a->flag.dec();
36  if (retval == 0 && a->usemutex) {
37  a->cond.signal();
38  }
39  a->mut.unlock();
40 }
41 
42 void stored_increment_counter(distributed_control &dc, procid_t src,
43  size_t ptr, dc_impl::blob ret) {
44  dc_impl::stored_ret_type *a = reinterpret_cast<dc_impl::stored_ret_type*>(ptr);
45  a->mut.lock();
46  a->val[src] = ret;
47  size_t retval = a->flag.dec();
48  if (retval == 0) {
49  a->cond.signal();
50  }
51  a->mut.unlock();
52 }
53 
54 }
55