Skip to content

Implement Go-Like Scala channels #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 132 commits into
base: base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
4f701c0
Add a skeleton of the future implementation.
yruslan Sep 30, 2020
3f94d81
Implement channels.
yruslan Oct 1, 2020
fc1d173
Implement select() with timeout.
yruslan Oct 1, 2020
4e70b5a
Add a test suite for send/recv.
yruslan Oct 1, 2020
5d523ef
Add unit tests for select(). Found a race condition when two workers …
yruslan Oct 5, 2020
af5f093
Fix what seemed like a race condition but actually a logic error.
yruslan Oct 7, 2020
faa08ba
Make channel API more like in Go.
yruslan Oct 7, 2020
265bcff
Add documentation for the features already implemented.
yruslan Oct 7, 2020
e974fca
Add directed channels and non-blocking waits on select().
yruslan Oct 8, 2020
b54cb8b
Add a couple of new features.
yruslan Oct 9, 2020
98b3fd2
Use Java semaphore instead of the crafted one.
yruslan Oct 9, 2020
3b86ea6
Add fornew() and generic worker builerplate example.
yruslan Oct 10, 2020
8be0429
Close() should block the synchronous channel until all pending messag…
yruslan Oct 11, 2020
f452052
Add non-blocking version of trySelect()
yruslan Oct 11, 2020
d65b801
Add documentation for closing of channels, channel iterations and non…
yruslan Oct 11, 2020
bcac59a
Add a simplistic sbt project with cross compilation for Scala 2.11, 2…
yruslan Oct 12, 2020
340880f
Add an alternative link to the Rob Pike's great talk.
yruslan Oct 13, 2020
4f83fb3
Add back tick syntax to README.
yruslan Oct 13, 2020
e2ef416
Do not expose channel's lock through its interface.
yruslan Oct 16, 2020
d8d6405
Make addWaited a conditional method so the outer call don't need to a…
yruslan Oct 16, 2020
4224465
Use more efficient mutable linked list container to store waiter sema…
yruslan Oct 17, 2020
14462f2
Change 'fornew()' to process only one message so that progress is gua…
yruslan Oct 18, 2020
a76b57c
Two new changes have been introduced:
yruslan Oct 22, 2020
5e087a2
Add a new way of selecting channels so that both senders and receiver…
yruslan Oct 23, 2020
3236452
Split between synchronous and asynchronous channels.
yruslan Oct 23, 2020
ae8e986
Split between synchronous and asynchronous channels.
yruslan Oct 24, 2020
4871ec8
Extract bounded waiting routines into a separate class.
yruslan Oct 25, 2020
5b9cec6
Change syntax of sender() to conform to Scala functional style.
yruslan Oct 26, 2020
e27b46a
Replace the old select() implementation with the new one.
yruslan Oct 28, 2020
eebe000
Update README to reflect the new select() syntax.
yruslan Oct 29, 2020
23001e2
Shutdown the executor used in channel's test suite.
yruslan Nov 9, 2020
6cf742d
Add a unit test for ensuring fairness of select()
yruslan Nov 16, 2020
472e89c
Make isCLosed synchronous since it can be called from a client code.
yruslan Nov 16, 2020
80277a6
Add release plugin
yruslan Feb 16, 2021
c3515c5
Setting version to 0.1.0
yruslan Feb 16, 2021
b0c2dde
Setting version to 0.1.1-SNAPSHOT
yruslan Feb 16, 2021
56f7467
Update Maven artifact name and Scala version
yruslan Feb 16, 2021
31a68b5
Merge pull request #2 from yruslan/prep_release_0_1_0
yruslan Feb 16, 2021
1522fd8
Add artifact links to README
yruslan Feb 17, 2021
215c5f9
Update the version of Scala 2.13
yruslan Feb 17, 2021
aa3a26e
Add the GitHub action for automated build
yruslan Feb 18, 2021
54d9e06
Add the build badge
yruslan Feb 21, 2021
d79ba46
Fix one corner cae of trySelect()
yruslan Apr 16, 2021
2b236fd
Improve fairness guarantee test suite to include async channels as well.
yruslan Apr 17, 2021
c709052
Create the changelog
yruslan Jun 7, 2021
10ff264
Setting version to 0.1.1
yruslan Jun 11, 2021
e5f80a8
Setting version to 0.1.2-SNAPSHOT
yruslan Jun 11, 2021
3260757
Update README
yruslan Jun 14, 2021
5a091d6
Merge pull request #6 from yruslan/prep_release_0_1_1
yruslan Jun 15, 2021
6b63b67
Update the version of the project in POM
yruslan Jun 16, 2021
ef21d65
Add more timing conditions to some unit tests
yruslan Jun 22, 2021
81a3344
#7 Add map() support for channels
yruslan Jan 4, 2022
5d76423
#7 Add filter() support for channels
yruslan Jan 5, 2022
1de8a17
#7 Add toList(), make foreach() and fornew() correspond to the standa…
yruslan Jan 6, 2022
daaf825
#7 Add withFilter(), so that for() comprehension could be used
yruslan Jan 7, 2022
5047dbc
#7 Add more tests for for comprehension
yruslan Jan 7, 2022
fdf13e7
#7 Update project and Scala version. Use Scala 2.13 in POM build
yruslan Jan 7, 2022
b182b14
Switch to Apache 2 license
yruslan Jan 7, 2022
7363cb5
Change the semantics of fornew()
yruslan Jan 8, 2022
1b1ff45
Make IntelliJ happy on the name clash in Scala 2.13 Maven project
yruslan Jan 9, 2022
995359e
Add a balancer example to README.md.
yruslan Jan 12, 2022
fe5e46f
Setting version to 0.1.2
yruslan Jan 13, 2022
40b90d9
Setting version to 0.1.3-SNAPSHOT
yruslan Jan 13, 2022
e5e1098
Update README post release
yruslan Jan 14, 2022
4a8866c
Merge pull request #9 from yruslan/prep_release_0_1_2
yruslan Jan 16, 2022
5ba163d
#10 Add support for unbounded buffered channels.
yruslan Mar 13, 2022
19e916f
Update README.
yruslan Mar 13, 2022
6072db1
Setting version to 0.1.3
yruslan Mar 13, 2022
8515456
Setting version to 0.1.4-SNAPSHOT
yruslan Mar 13, 2022
22932af
Bump up the version in the POM file.
yruslan Mar 13, 2022
15bbefb
Merge pull request #11 from yruslan/feature/10-add-support-for-unboun…
yruslan Mar 13, 2022
67763f8
Add support of covariance and contravariance for channels.
yruslan Sep 3, 2022
90a6581
Update Scala compiler versions to the latest patch.
yruslan Sep 3, 2022
d3253b0
Setting version to 0.1.4
yruslan Sep 8, 2022
52b648a
Setting version to 0.1.5-SNAPSHOT
yruslan Sep 8, 2022
8bfd046
Update README and the POM project file.
yruslan Sep 8, 2022
eb44bbf
Merge pull request #13 from yruslan/prep_release_0_1_4
yruslan Sep 8, 2022
fa2d78a
Update project dependencies.
yruslan Feb 4, 2023
81b405a
Remove the POM file since it was used before IDEs had good sbt integr…
yruslan Nov 24, 2023
effe843
#16 Implement guards against InterruptedException
yruslan Nov 25, 2023
5d65ccb
Update Scala patch versions.
yruslan Nov 25, 2023
d4ed074
Fix blocking of foreach() if the waiting thread is interrupted.
yruslan Nov 26, 2023
9d685ec
Catch all throwables while waiting, not just InterruptedException.
yruslan Nov 26, 2023
0fe0a2a
Fix the ping-pong test to use 2 channels.
yruslan Nov 26, 2023
5e31fa7
#15 Add support for priority prioritySelect() for channels.
yruslan Nov 26, 2023
6acc30a
Setting version to 0.1.5
yruslan Nov 26, 2023
b7e1d18
Setting version to 0.1.6-SNAPSHOT
yruslan Nov 26, 2023
2660444
Update to the latest sbt.
yruslan Nov 26, 2023
3176fe8
Merge pull request #19 from yruslan/prep_release_0_1_5
yruslan Nov 26, 2023
2bc02e2
#20 Fix the bug in 'channel.filter(...)'.
yruslan Nov 28, 2023
f98f0fa
#20 Add more tests for edge cases.
yruslan Nov 29, 2023
f093b46
Fix the license from MIT to Apache in artifact properties.
yruslan Nov 30, 2023
6313ddd
Add an entry about v0.1.5 to README.
yruslan Nov 30, 2023
086b578
Simplify the code for trySend() with a timeout a little bit.
yruslan Dec 2, 2023
feb5e7f
Setting version to 0.1.6
yruslan Dec 2, 2023
bd9a7b7
Setting version to 0.1.7-SNAPSHOT
yruslan Dec 2, 2023
0f64e74
Merge pull request #25 from yruslan/prep_release_0_1_6
yruslan Dec 2, 2023
1926b6d
Update README.md
yruslan Dec 4, 2023
1a08131
#22 Implement select() logic for synchronous channels that match GoLang.
yruslan Dec 3, 2023
8b0edb8
#22 Simplify the implementation of strict select() for synchronous ch…
yruslan Dec 8, 2023
cf25c1e
#22 Move internal methods from ChannelLike to ChannelImpl interface.
yruslan Dec 9, 2023
6f484d6
#22 Simplify the code of select() and improve its performance.
yruslan Dec 10, 2023
7a37e97
#22 Add compiler optimizations for Scala 2.12 and 2.13.
yruslan Dec 10, 2023
602bd7c
Target Scala 2.11 version of the library for JVM 1.8 as well.
yruslan Dec 10, 2023
a65d2ef
#23 Implement the default section for select().
yruslan Dec 16, 2023
048543c
#23 Improve the performance of select() in a tiny bit.
yruslan Dec 16, 2023
5cc03dd
#23 Make default() part of the object, not part of the Channel class.
yruslan Dec 17, 2023
4c10aea
#23 Add the info about the new feature to README.
yruslan Dec 20, 2023
95de253
Remove redundant imports and comments.
yruslan Dec 30, 2023
853479e
#24 Implement 'after' and 'tick' time channel generators.
yruslan Jan 4, 2024
90e0b63
#24 Add unit tests for tickers and Time.after().
yruslan Jan 5, 2024
d76bb83
#24 Add the description to README about the new feature.
yruslan Jan 7, 2024
a61828a
Rename object 'Time' -> 'TimeChannels' since 'Time' can be confused w…
yruslan Jan 11, 2024
d9dbce5
Bump up the version number to 0.2.0.
yruslan Feb 24, 2024
1c7f148
Setting version to 0.2.0
yruslan Feb 29, 2024
51be305
Setting version to 0.2.1-SNAPSHOT
yruslan Feb 29, 2024
8f486a4
Update README.
yruslan Mar 2, 2024
d0a77e1
Merge pull request #29 from yruslan/prep_release_0_2_0
yruslan Mar 3, 2024
3fbd1cc
Update Scala, Spark and sbt to latest patch versions.
yruslan Apr 1, 2024
6a02e51
#30 Implement port of Goland WaitGroup.
yruslan Apr 7, 2024
0d02370
Fix `isClosed()` for async channels.
yruslan Apr 7, 2024
a050e13
Add throughput and latency measurements to test suites.
yruslan Apr 9, 2024
7b7a3e0
Improve performance of time-based channels.
yruslan Apr 20, 2024
075c381
Add info about WaitGroup to README.
yruslan Apr 21, 2024
48cc47b
Fix timing issues of several unit tests.
yruslan Apr 28, 2024
e11cd28
Setting version to 0.2.1
yruslan May 11, 2024
f1def5d
Setting version to 0.2.2-SNAPSHOT
yruslan May 11, 2024
a3e0823
Merge pull request #33 from yruslan/prep_release_0_2_1
yruslan May 11, 2024
bc24131
Update README.
yruslan May 11, 2024
6c68b45
Add VsCode and plugin files to gitignore.
yruslan May 25, 2025
5c57d98
Remove GitHub CI cache plugin which is no longer supported.
yruslan May 25, 2025
1bb75a9
Use GitHub CI image with sbt.
yruslan May 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build-sbt:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
scala: [ 2.11.12, 2.12.19, 2.13.13 ]
name: Scala ${{matrix.scala}}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK and sbt
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt
- name: Build and run tests
run: sbt ++${{matrix.scala}} test
39 changes: 38 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# use glob syntax.
syntax: glob
*.ser
*.class
*.log
*~
*.bak
*.old
.DS_Store

# eclipse conf file
.settings
.classpath
.manager
.scala_dependencies

# VsCode
.project
.bloop
.metals
metals.sbt
settings.json
sbt.json

# idea
.idea
*.iml

# building
target
build
null
tmp*
temp*
dist
test-output
build.log

.cache*
dependency-reduced-pom.xml
223 changes: 202 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,202 @@
MIT License

Copyright (c) 2020 Ruslan Yushchenko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading