{"id":24491425,"url":"https://github.com/vxcontrol/rmx","last_synced_at":"2025-03-15T02:25:27.148Z","repository":{"id":57516653,"uuid":"190885289","full_name":"vxcontrol/rmx","owner":"vxcontrol","description":"Recursive mutex implementation by goroutine ID","archived":false,"fork":false,"pushed_at":"2023-05-05T13:31:11.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T18:18:06.010Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vxcontrol.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":"2019-06-08T12:27:53.000Z","updated_at":"2023-04-04T10:45:35.000Z","dependencies_parsed_at":"2022-09-26T18:01:23.466Z","dependency_job_id":null,"html_url":"https://github.com/vxcontrol/rmx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxcontrol%2Frmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxcontrol%2Frmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxcontrol%2Frmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vxcontrol%2Frmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vxcontrol","download_url":"https://codeload.github.com/vxcontrol/rmx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243673502,"owners_count":20328928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-01-21T18:18:08.977Z","updated_at":"2025-03-15T02:25:27.130Z","avatar_url":"https://github.com/vxcontrol.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Recursive mutex implementation by goroutine ID\n\nIn the Golang world there is the problem that getting goroutine ID for any tasks.\nBut you can find [sad information](https://golang.org/doc/faq#no_goroutine_id) on the [FAQ page](https://golang.org/doc/faq) of the Golang documentation in [Rob Pike's comment](https://go.googlesource.com/go/+/992ce90f662467f04dd93b3bb565bb0414f82999%5E%21/#F0) that getting ID is imposible.\nWe disagree with it and think that this should be present in Golang because often needs to use shared object in goroutine safe mode.\n\nRequires go version \u003e= 1.19 for \"Fast\" mode.\n\nThis project gives possibility to use recursive mutex in two modes:\n- \"Generic\" that provides access to goroutine ID from runtime.stack call\n- \"Fast\" that provides the same access from reflective call to \"runtime\" internal object\n\nMotivation of using both modes:\n- \"Generic\" is common mode that will be to work for any Golang version\n- \"Fast\" is specific mode that will be to work only limited Golang version because it's using offset to search goroutine ID in \"runtime\" object but that work faster about 100 times than \"Generic\" mode\n\nUse cases:\n- Install the package\n\n```bash\ngo get github.com/vxcontrol/rmx\n```\n\n- \"Generic\" mode if tests were failed\n\n```go\nimport \"github.com/vxcontrol/rmx\"\n\t// Some code\n\trm := \u0026rmx.Mutex{ IsGeneric: true }\n\t\t// Using inside of recursive function\n\t\trm.Lock()\n\t\t// Goroutine safe code\n\t\trm.Unlock()\n```\n\n- \"Fast\" mode if tests were passed\n\n```go\nimport \"github.com/vxcontrol/rmx\"\n\t// Some code\n\trm := \u0026rmx.Mutex{ IsGeneric: false } // Option value by default\n\t\t// Using inside of recursive function\n\t\trm.Lock()\n\t\t// Goroutine safe code\n\t\trm.Unlock()\n```\n\n- Override default waiting time before next check mutex for highload applications\nUse \"-1\" constant value to disable waiting (just force to run schedule goroutine process)\nUse \"0\" constant by default value to wait a minimal delay about 1ms\nUse \"\u003e1\" constant value to wait a longer time in milliseconds\n\n```go\nimport \"github.com/vxcontrol/rmx\"\n\t// Some code\n\trm := \u0026rmx.Mutex{ TimeWaitMS: 5 } // Wait 5ms\n\t\t// Using inside of recursive function\n\t\trm.Lock()\n\t\t// Goroutine safe code\n\t\trm.Unlock()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvxcontrol%2Frmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvxcontrol%2Frmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvxcontrol%2Frmx/lists"}