Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:00:11

0001 /**
0002  * Copyright (c) 2017-present, Facebook, Inc.
0003  * All rights reserved.
0004  *
0005  * This source code is licensed under the BSD-style license found in the
0006  * LICENSE file in the root directory of this source tree.
0007  */
0008 
0009 #pragma once
0010 
0011 #include "gloo/algorithm.h"
0012 #include "gloo/context.h"
0013 #include "gloo/transport/unbound_buffer.h"
0014 
0015 namespace gloo {
0016 
0017 class Barrier : public Algorithm {
0018  public:
0019   explicit Barrier(const std::shared_ptr<Context>& context)
0020       : Algorithm(context) {}
0021 
0022   virtual ~Barrier(){};
0023 };
0024 
0025 class BarrierOptions {
0026  public:
0027   explicit BarrierOptions(const std::shared_ptr<Context>& context);
0028 
0029   void setTag(uint32_t tag) {
0030     this->tag = tag;
0031   }
0032 
0033   void setTimeout(std::chrono::milliseconds timeout) {
0034     this->timeout = timeout;
0035   }
0036 
0037  protected:
0038   std::shared_ptr<Context> context;
0039   std::unique_ptr<transport::UnboundBuffer> buffer;
0040 
0041   // Tag for this operation.
0042   // Must be unique across operations executing in parallel.
0043   uint32_t tag = 0;
0044 
0045   // End-to-end timeout for this operation.
0046   std::chrono::milliseconds timeout;
0047 
0048   friend void barrier(BarrierOptions&);
0049 };
0050 
0051 void barrier(BarrierOptions& opts);
0052 
0053 } // namespace gloo