{"id":23684885,"url":"https://github.com/chrsm/weave","last_synced_at":"2026-04-28T12:02:06.681Z","repository":{"id":130399836,"uuid":"397139661","full_name":"chrsm/weave","owner":"chrsm","description":"Thread-management library for LOVE2D.","archived":false,"fork":false,"pushed_at":"2021-08-17T06:51:02.000Z","size":4,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-22T00:10:09.510Z","etag":null,"topics":["love2d","love2d-library","lua","moonscript","yuescript"],"latest_commit_sha":null,"homepage":"","language":"MoonScript","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/chrsm.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-17T06:48:30.000Z","updated_at":"2025-03-28T11:03:24.000Z","dependencies_parsed_at":"2023-06-26T09:30:28.988Z","dependency_job_id":null,"html_url":"https://github.com/chrsm/weave","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chrsm/weave","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrsm%2Fweave","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrsm%2Fweave/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrsm%2Fweave/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrsm%2Fweave/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrsm","download_url":"https://codeload.github.com/chrsm/weave/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrsm%2Fweave/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32379629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["love2d","love2d-library","lua","moonscript","yuescript"],"created_at":"2024-12-29T20:49:00.623Z","updated_at":"2026-04-28T12:02:06.551Z","avatar_url":"https://github.com/chrsm.png","language":"MoonScript","funding_links":[],"categories":["Love2D"],"sub_categories":["emacs"],"readme":"weave\n======\n\n`weave` is a wrapper around LOVE2D's [`love.thread`][1], written in [Yuescript][2].\n\nYou can build this repo from source with `make build` or download a [release][3].\n\n\nAPI\n===\n\n`weave` has two concepts: the Manager and the Thread.\n\n`weave.Manager` handles creation, error checking and sending messages for\nthreads.\n\n`weave.Thread` handles the \"event loop\" of receiving messages for threads from\nthe manager.\n\n```\nweave.Manager\n\tweave.Manager\n\t\tctor\n\n\t:update(dt)\n\t\tShould be called every `love.update`.\n\t\tThis checks for errors from the thread and removes threads if\n\t\tthey have signaled they will be exiting.\n\n\t\tNote that errors will be overwritten, if you wish to check for\n\t\tthem, you should do it after calling Manager:update.\n\n\t\tIn other words, call Manager:update before all other code in\n\t\t`love.update`.\n\n\t:createThread(name, src)\n\t\tsrc can be a filename, LOVE FileData, or raw lua code.\n\n\t\tCreates a new thread by name - if it doesn't exist.\n\t\tRaises an error if it does.\n\n\t\tStarts the thread immediately.\n\t\n\t:getError(name)\n\t\tReturns the most recent error for a thread.\n\t\n\t:has(name)\n\t\tReturns true if the Manager has already tracked a thread by\n\t\tthis name.\n\t\n\t:kill(name)\n\t\tForcibly terminates a thread regardless of its status.\n\n\t\tRaises an error if it does not exist.\n\n\t:send(name, recv love.thread.Channel|nil, ... any)\n\t\tSends a message to a running thread.\n\n\t\tIf `recv` is specified, the Thread will return the result\n\t\tof its handler call on the recv channel.\n\n\t\tRaises an error if the thread does not exist.\n\nweave.Thread\n\tweave.Thread(name)\n\t\tctor\n\n\t:setHandler(fn)\n\t\tSets the handler for this thread.\n\n\t\tHandlers receive a message from the Manager, and contain\n\t\tany arguments passed to it.\n\n\t\tIf results should be able to be passed back to the caller,\n\t\tthe result should be returned from it.\n\n\t:destroy()\n\t\tNotifies the Manager of intent-to-exit, and stops at the end\n\t\tof the next run loop.\n\n\t\tClears all current messages in the channel.\n\n\t:read()\n\t\tWaits for a message on the channel and executes @handler on it.\n\n\t\tRaises an error if the message is falsy from ch:demand.\n\n\t:run()\n\t\tStarts the Thread, continually running until exit is set to\n\t\ttrue.\n\t\n```\n\n\nExample\n=======\n\nWhile use of threads is always usecase-specific, here's a very trivial example.\n\nWe'll use a single file for this case. In practice, it's cleaner to write your\nworker separately from where it is managed.\n\n```lua\nlocal weave = require(\"weave\")\nlocal manager = weave.Manager()\nlocal recv = love.thread.newChannel()\n\nlocal source = [[\nlocal weave = require(\"weave\")\n\nlocal thr = weave.Thread(\"add_ten\")\n\nthr:setHandler(function(n1, n2)\n  if type(n1) ~= \"number\" or type(n2) ~= \"number\" then\n    return { err: \"n1 or n2 not a number\" }\n  end\n\n  return { n1+10, n2+10 }\nend)\n\nthr:run()\n]]\n\nfunction love.load()\n  manager:createThread(\"add_ten\", source)\nend\n\nfunction love.update(dt)\n  manager:update(dt)\n\n  err = manager:getError(\"add_ten\")\n  if err != nil then\n    print(\"error encountered in thread: \" .. err)\n  end\nend\n\nfunction love.draw()\n  -- not drawing anything, just logging to console\n  local r = recv:pop()\n  if r then\n    print(\"received results: \" .. tostring(r[1]) .. \", \" .. tostring(r[2]))\n  end\nend\n\nfunction love.keypressed(key)\n  if key == \"1\" then\n    manager:send(\"add_ten\", nil, \"error pls\", \"pls error\")\n  elseif key == \"2\" then\n    manager:send(\"add_ten\", recv, 10, 20)\n  elseif key == \"3\" then\n    love.event.quit()\n  end\nend\n\n```\n\n[1]: https://love2d.org/wiki/Thread\n[2]: https://github.com/pigpigyyy/Yuescript\n[3]: https://github.com/chrsm/weave\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrsm%2Fweave","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrsm%2Fweave","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrsm%2Fweave/lists"}