Flow scope (#1227)

* Introducing flowScope, builder necessary for creating cancellation-transparent flow operators
* Incorporate flow scope into flow operators

Fixes #1218
Fixes #1128
diff --git a/kotlinx-coroutines-core/jvm/src/flow/internal/FlowExceptions.kt b/kotlinx-coroutines-core/jvm/src/flow/internal/FlowExceptions.kt
new file mode 100644
index 0000000..d8d4d21
--- /dev/null
+++ b/kotlinx-coroutines-core/jvm/src/flow/internal/FlowExceptions.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package kotlinx.coroutines.flow.internal
+
+import kotlinx.coroutines.*
+
+internal actual class AbortFlowException : CancellationException("Flow was aborted, no more elements needed") {
+    override fun fillInStackTrace(): Throwable {
+        if (DEBUG) super.fillInStackTrace()
+        return this
+    }
+}
+
+internal actual class ChildCancelledException : CancellationException("Child of the scoped flow was cancelled") {
+    override fun fillInStackTrace(): Throwable {
+        if (DEBUG) super.fillInStackTrace()
+        return this
+    }
+}