{"id":13508989,"url":"https://github.com/costaraphael/cspex","last_synced_at":"2026-02-21T13:01:15.232Z","repository":{"id":57487407,"uuid":"49758285","full_name":"costaraphael/cspex","owner":"costaraphael","description":"A library that brings all the CSP joy to the Elixir land.","archived":false,"fork":false,"pushed_at":"2018-06-28T06:39:29.000Z","size":194,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-14T07:33:59.316Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/costaraphael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-16T03:55:45.000Z","updated_at":"2024-11-26T15:30:37.000Z","dependencies_parsed_at":"2022-09-01T23:02:37.138Z","dependency_job_id":null,"html_url":"https://github.com/costaraphael/cspex","commit_stats":null,"previous_names":["vidalraphael/cspex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/costaraphael/cspex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costaraphael%2Fcspex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costaraphael%2Fcspex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costaraphael%2Fcspex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costaraphael%2Fcspex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/costaraphael","download_url":"https://codeload.github.com/costaraphael/cspex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/costaraphael%2Fcspex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29681468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T12:30:22.644Z","status":"ssl_error","status_checked_at":"2026-02-21T12:29:55.402Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:01.444Z","updated_at":"2026-02-21T13:01:15.179Z","avatar_url":"https://github.com/costaraphael.png","language":"Elixir","readme":"# CSPEx\n\n[![Hex.pm](https://img.shields.io/hexpm/v/cspex.svg?style=flat-square)](https://hex.pm/packages/cspex)\n[![Hex.pm](https://img.shields.io/hexpm/dt/cspex.svg?style=flat-square)](https://hex.pm/packages/cspex)\n\n\nA library that brings all the [CSP](https://en.wikipedia.org/wiki/Communicating_sequential_processes) joy to the Elixir land.\n\nThe aim of this library is to make it simple to work with [CSP channels](https://en.wikipedia.org/wiki/Channel_(programming))\nalongside Elixir actors and supervision trees, so that we can have\nanother tool in our pockets, choosing it where it fits best.\n\nHighly inspired on Go channels and Clojure core.async library.\n\nSuggestions and pull requests are more than welcome.\n\n## Examples\n\nYou can simply create a channel and pass it to other processes:\n\n```elixir\nchannel = Channel.new\n\npid = spawn_link fn -\u003e\n  # This line will block until the data is read\n  Channel.put(channel, :some)\n  Channel.put(channel, :data)\nend\n\nProcess.alive?(pid) #=\u003e true\n\nChannel.get(channel) #=\u003e :some\nProcess.alive?(pid) #=\u003e true\n\nChannel.get(channel) #=\u003e :data\nProcess.alive?(pid) #=\u003e false\n```\n\nOr you can use a channel as part of a supervision tree:\n\n```elixir\nimport Supervisor.Spec\n\nchildren = [\n  worker(Channel, [[name: MyApp.Channel]])\n]\n\n{:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)\n\nspawn_link fn -\u003e\n  # This line will block until some data is written to the channel\n  data = Channel.get(MyApp.Channel)\n\n  IO.puts \"I read #{inspect data} from the channel.\"\nend\n\nChannel.put(MyApp.Channel, :data)\n```\n\nIn any of the cases you can use a channel like any Enumerable or Colectable:\n\n```elixir\n# Wraps the process name into a channel struct\n# Works with PIDs too\nmy_channel = Channel.wrap(MyApp.Channel)\n\nspawn_link fn -\u003e\n  # Blocks until all the values can be written\n  Enum.into(1..10, my_channel)\nend\n\n# The buffer size means how many values I can put in a channel until it\n# starts blocking.\nother_channel = Channel.new(buffer_size: 10)\n\n# The code bellow will block until the channel \"my_channel\" is closed.\nfor x \u003c- my_channel, into: other_channel do\n  x * 2\nend\n```\n\n## Installing\n\nAdd the dependency to the mix.exs file:\n\n```elixir\ndeps: [{:cspex, \"~\u003e x.x.x\"}, ...]\n```\n\nAdd the following snippet to anywhere you want to use it:\n\n```elixir\nuse CSP\n```\n\nBe happy!\n\n## Documentation\n\nOnline documentation is available [here](http://hexdocs.pm/cspex).\n\n## License\n\nThe CSPEx source code is licensed under the [MIT License](https://github.com/costaraphael/cspex/blob/master/LICENSE)\n","funding_links":[],"categories":["Queue"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostaraphael%2Fcspex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcostaraphael%2Fcspex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcostaraphael%2Fcspex/lists"}