{"id":37207303,"url":"https://github.com/satrobit/go-pthreads","last_synced_at":"2026-01-14T23:50:42.319Z","repository":{"id":56761360,"uuid":"278189074","full_name":"satrobit/go-pthreads","owner":"satrobit","description":"POSIX Threads (pthreads) bindings in Go","archived":false,"fork":false,"pushed_at":"2020-07-08T20:54:16.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T11:51:12.898Z","etag":null,"topics":["go","golang","pthread","thread"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satrobit.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":"2020-07-08T20:33:49.000Z","updated_at":"2024-06-20T11:51:12.899Z","dependencies_parsed_at":"2022-08-16T02:00:50.895Z","dependency_job_id":null,"html_url":"https://github.com/satrobit/go-pthreads","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/satrobit/go-pthreads","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrobit%2Fgo-pthreads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrobit%2Fgo-pthreads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrobit%2Fgo-pthreads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrobit%2Fgo-pthreads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satrobit","download_url":"https://codeload.github.com/satrobit/go-pthreads/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrobit%2Fgo-pthreads/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28439559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","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":["go","golang","pthread","thread"],"created_at":"2026-01-14T23:50:40.700Z","updated_at":"2026-01-14T23:50:42.310Z","avatar_url":"https://github.com/satrobit.png","language":"Go","readme":"go-pthreads\n===========\n\nThis is a binding of C's pthreads to Google Go. **This library is not a\nreplacement for goroutines.** This library is designed to help bind C libraries\nwith blocking function calls to Go in a go-friendly manner. If this is not your\nuse case, this library probably won't help you.\n\nThis is a fork of [liamzdenek/go-pthreads](https://github.com/liamzdenek/go-pthreads).\n\nI will be making substantial changes to this repository over the next few months so interface isn't stable and no version will be released until a stable interface achieved.\n\n\nUse Case\n--------\n\nIf a goroutine exists that calls a function that will block potentially\nindefinitely, that goroutine cannot be stopped until the blocking function\nreturns and the goroutine checks an \"exit\" channel, and exits of its own will.\n\nIn every day go programming, this condition should not exist, as all inter-\nthread communication, as well as reading and writing, should be done using\nchannels. However, in C, many libraries (and, in my specific case, networking\nlibraries) implement blocking functions (recv), and the mixture of a blocking\nfunction and a multi-channel select caused many implementation problems and\n\"hacks\" to get the \"blocking\" function to return periodically, so the exit\nchannel could be checked, and the routine could exit if it had to.\n\nExample\n-------\n\n```go\npackage main;\n\nimport (\n\t\"github.com/liamzdenek/go-pthreads\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tthread := pthread.Create(func() {\n\t\t// we're within the pthread\n\t\tcounter := 1;\n\t\tfor {\n\t\t\t// time to make a blocking function call. The library includes\n\t\t\t// pthread.sleep for demo purposes, but this will work with any\n\t\t\t// library that causes IO wait\n\t\t\n\t\t\t// an example using github.com/alecthomas/gozmq can be found in\n\t\t\t// Thread_test.go\n\n\t\t\tfmt.Printf(\"Hello, %d\\n\", counter)\n\t\t\tcounter++\n\t\t\tpthread.Sleep(1) // seconds\n\t\t}\n\t})\n\n\t// within the main goroutine\n\tpthread.Sleep(3)\n\n\tfmt.Printf(\"Killing thread\\n\");\n\tthread.Kill()\n\n\tpthread.Sleep(3);\n}\n```\n\nOutput:\n```\n$ time go run test.go\nHello, 1\nHello, 2\nHello, 3\nKilling thread\ngo run test.go  0.28s user 0.09s system 5% cpu 6.421 total\n```\n\nPros/Cons\n---------\n\nPros:\n\n* Provides a mechanism to kill a blocked thread (thread.Kill())\n* Provides thread status without any logic in the child (thread.Running())\n\nCons:\n\n* Does not implement pthread_cleanup_push/pop\n* Runs in a dedicated thread (most of the time; sometimes this is a pro)\n* Does not integrate with the go scheduler (as a consequence of the new thread)\n* Harder to debug (crashes in C code don't produce stack traces)\n\nCredits\n---------\nThis repository is based on [liamzdenek/go-pthreads](https://github.com/liamzdenek/go-pthreads)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrobit%2Fgo-pthreads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatrobit%2Fgo-pthreads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrobit%2Fgo-pthreads/lists"}