blob: 689e36fea44e99bee828c57e31634565d840bf53 [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
2 * Copyright 2016-2017 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Roman Elizarov187eace2017-01-31 09:39:58 +030017package kotlinx.coroutines.experimental.channels
18
Roman Elizarov187eace2017-01-31 09:39:58 +030019/**
20 * Rendezvous channel. This channel does not have any buffer at all. An element is transferred from sender
21 * to receiver only when [send] and [receive] invocations meet in time (rendezvous), so [send] suspends
22 * until another coroutine invokes [receive] and [receive] suspends until another coroutine invokes [send].
Roman Elizarov7b2d8b02017-02-02 20:09:14 +030023 *
Roman Elizarovf2a710a2017-07-21 18:33:59 +030024 * Use `Channel()` factory function to conveniently create an instance of rendezvous channel.
25 *
Roman Elizarov7b2d8b02017-02-02 20:09:14 +030026 * This implementation is fully lock-free.
Roman Elizarov187eace2017-01-31 09:39:58 +030027 */
Roman Elizarov0a788392017-02-15 17:52:12 +030028public open class RendezvousChannel<E> : AbstractChannel<E>() {
Roman Elizarov2ad0e942017-02-28 19:14:08 +030029 protected final override val isBufferAlwaysEmpty: Boolean get() = true
Roman Elizarov0a788392017-02-15 17:52:12 +030030 protected final override val isBufferEmpty: Boolean get() = true
Roman Elizarov2ad0e942017-02-28 19:14:08 +030031 protected final override val isBufferAlwaysFull: Boolean get() = true
Roman Elizarov0a788392017-02-15 17:52:12 +030032 protected final override val isBufferFull: Boolean get() = true
Roman Elizarov187eace2017-01-31 09:39:58 +030033}