Thrill  0.1
discard_sink.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * thrill/data/discard_sink.hpp
3  *
4  * Part of Project Thrill - http://project-thrill.org
5  *
6  * Copyright (C) 2015 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the BSD-2 license in the LICENSE file.
9  ******************************************************************************/
10 
11 #pragma once
12 #ifndef THRILL_DATA_DISCARD_SINK_HEADER
13 #define THRILL_DATA_DISCARD_SINK_HEADER
14 
15 #include <thrill/data/block.hpp>
18 
19 namespace thrill {
20 namespace data {
21 
22 //! \addtogroup data_layer
23 //! \{
24 
25 /*!
26  * DiscardSink is an BlockSink that discards all Blocks delivered to it. Use it
27  * for benchmarking!
28  */
29 class DiscardSink final : public BlockSink
30 {
31 public:
32  //! Create discarding BlockSink.
34  : BlockSink(block_pool, local_worker_id)
35  { }
36 
37  //! Discards a Block.
38  void AppendBlock(const Block&, bool) final { }
39 
40  //! Discards a Block.
41  void AppendBlock(Block&&, bool) final { }
42 
43  //! Closes the sink
44  void Close() final {
45  assert(!closed_);
46  closed_ = true;
47  }
48 
49  //! return close flag
50  bool closed() const { return closed_; }
51 
52  //! boolean flag whether to check if AllocateByteBlock can fail in any
53  //! subclass (if false: accelerate BlockWriter to not be able to cope with
54  //! nullptr).
55  static constexpr bool allocate_can_fail_ = false;
56 
57 private:
58  bool closed_ = false;
59 };
60 
62 
63 //! \}
64 
65 } // namespace data
66 } // namespace thrill
67 
68 #endif // !THRILL_DATA_DISCARD_SINK_HEADER
69 
70 /******************************************************************************/
Block combines a reference to a read-only ByteBlock and book-keeping information. ...
Definition: block.hpp:52
static constexpr bool allocate_can_fail_
BlockWriter contains a temporary Block object into which a) any serializable item can be stored or b)...
void AppendBlock(const Block &, bool) final
Discards a Block.
void Close() final
Closes the sink.
Pool to allocate, keep, swap out/in, and free all ByteBlocks on the host.
Definition: block_pool.hpp:42
DiscardSink is an BlockSink that discards all Blocks delivered to it.
size_t local_worker_id() const
local worker id to associate pinned block with
Definition: block_sink.hpp:94
BlockPool * block_pool() const
Returns block_pool_.
Definition: block_sink.hpp:69
bool closed() const
return close flag
DiscardSink(BlockPool &block_pool, size_t local_worker_id)
Create discarding BlockSink.
Pure virtual base class for all things that can receive Blocks from a BlockWriter.
Definition: block_sink.hpp:28
void AppendBlock(Block &&, bool) final
Discards a Block.