channels
Version, currently master branch1 version
- master branchlatestJan 2, 2020
github.com/btihen/crystal_channels
Playing with Channels and Parellelism
Installation
# Add this to your shard.yml
dependencies:
channels:
github: btihen/crystal_channels
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.32.1- License
- MIT
- Author
- Bill Tihen
- Target
channelsfrom src/channels.cr
Dependencies
This version declares no dependencies.
README
channels
This uses channels back and forth between users and chat rooms.
CODE
- src_01_direct - users directly messaging each other over channels 1 to 1
- src_02_chat - users subscribe to a chat room - now we can do 1 to many over channels. Now Fibers are interesting. With one thread (& one output window its all readable). With multi-threading (& one output window) - output is no longer readable.
- src_03_parellelism - TOTO: write chat with each user having separate sessions / windows so outputs don't get jumbled
Questions
- how to I stop program AFTER all thread and fibers are finished!
Installation
1 thread compile crystal build --release src/chat_channels.cr -o ./chat_channels
compile with parellelism crystal build --release -Dpreview_mt src/chat_channels.cr -o ./chat_channels
Usage
run in one big thread ./chat_channels or crystal run src/chat_channels.cr
run in parrell time ./channels # default workers is 4 time CRYSTAL_WORKERS=2 ./channels time CRYSTAL_WORKERS=4 ./channels (very hard to read -without each user having their own tcp-session / or window) - messages get all jumbled in one output window)
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Jan 2, 2020
- Crystal
0.32.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/btihen/crystal_channels
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 17, 2026
- Synced
- Aug 17, 2026
- Versions
- 1