Skip to content

Commit

Permalink
chore(*) drop limitset functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jul 29, 2022
1 parent 6251ad0 commit 9eb42dc
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 233 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ install:
cp src/copas/ftp.lua $(DESTDIR)$(LUA_DIR)/copas/ftp.lua
cp src/copas/smtp.lua $(DESTDIR)$(LUA_DIR)/copas/smtp.lua
cp src/copas/http.lua $(DESTDIR)$(LUA_DIR)/copas/http.lua
cp src/copas/limit.lua $(DESTDIR)$(LUA_DIR)/copas/limit.lua
cp src/copas/timer.lua $(DESTDIR)$(LUA_DIR)/copas/timer.lua
cp src/copas/lock.lua $(DESTDIR)$(LUA_DIR)/copas/lock.lua
cp src/copas/semaphore.lua $(DESTDIR)$(LUA_DIR)/copas/semaphore.lua
Expand All @@ -48,7 +47,6 @@ test: certs
$(LUA) $(DELIM) $(PKGPATH) tests/exittest.lua
$(LUA) $(DELIM) $(PKGPATH) tests/httpredirect.lua
$(LUA) $(DELIM) $(PKGPATH) tests/largetransfer.lua
$(LUA) $(DELIM) $(PKGPATH) tests/limit.lua
$(LUA) $(DELIM) $(PKGPATH) tests/lock.lua
$(LUA) $(DELIM) $(PKGPATH) tests/loop_starter.lua
$(LUA) $(DELIM) $(PKGPATH) tests/queue.lua
Expand Down
1 change: 0 additions & 1 deletion Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ install:
copy src\copas\ftp.lua "$(LUA_DIR)\copas\ftp.lua"
copy src\copas\smtp.lua "$(LUA_DIR)\copas\smtp.lua"
copy src\copas\http.lua "$(LUA_DIR)\copas\http.lua"
copy src\copas\limit.lua "$(LUA_DIR)\copas\limit.lua"
copy src\copas\timer.lua "$(LUA_DIR)\copas\timer.lua"
copy src\copas\lock.lua "$(LUA_DIR)\copas\lock.lua"
1 change: 0 additions & 1 deletion copas-cvs-6.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ build = {
["copas.http"] = "src/copas/http.lua",
["copas.ftp"] = "src/copas/ftp.lua",
["copas.smtp"] = "src/copas/smtp.lua",
["copas.limit"] = "src/copas/limit.lua",
["copas.timer"] = "src/copas/timer.lua",
["copas.lock"] = "src/copas/lock.lua",
["copas.semaphore"] = "src/copas/semaphore.lua",
Expand Down
4 changes: 4 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ <h2><a name="history"></a>History</h2>
<dl class="history">
<dt><strong>Copas x.x.x</strong> [unreleased]</dt>
<dd><ul>
<li>[breaking] Change: removed the "limitset". Its functionality can easily be recreated with
the new "queue" class, which is a better abstraction.</li>
<li>[breaking] Change: threads added through <code>copas.addthread</code> or
<code>copas.addnamedthread</code> will now be "scheduled", instead of immediately started.</li>
<li>Fixed: yielding to the Copas scheduler from user-code now throws a proper error and
no longer breaks the loop. Breaking the loop could also happen if a thread returned with
at least 2 return values.</li>
Expand Down
15 changes: 0 additions & 15 deletions docs/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -548,21 +548,6 @@ <h3>High level request functions</h3>
module is a drop-in replacement for the <code>socket.smtp</code> module
</dd>

<dt><strong><code>copas.limit.new(max)</code></strong></dt>
<dd>Creates and returns a `limitset` that limits the concurrent tasks to <code>max</code> number
of running tasks. Eg. 100 http requests, in a set with <code>max == 10</code>, then no more than
10 requests will be performed simultaneously. Only when a request finishes, the next will be started.
</dd>

<dt><strong><code>limitset:addthread(func [, ...])</code></strong></dt>
<dd>Identical to <code>copas.addthread</code>, except that it operates within the limits of
the set of running tasks.
</dd>

<dt><strong><code>limitset:wait()</code></strong></dt>
<dd>Will yield until all tasks in the set have finished.
</dd>

</dl>

<h3>Low level Copas functions</h3>
Expand Down
5 changes: 1 addition & 4 deletions src/copas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1131,10 +1131,7 @@ function copas.addnamedthread(handler, name, ...)
-- create a coroutine that skips the first argument, which is always the socket
-- passed by the scheduler, but `nil` in case of a task/thread
local thread = coroutine_create(function(_, ...)
-- TODO: this should be added to not immediately execute the thread
-- it should only schedule and then return to the calling code
-- Enabling this breaks the "limitset".
-- copas.sleep(0)
copas.sleep(0)
return handler(...)
end)
if name then
Expand Down
136 changes: 0 additions & 136 deletions src/copas/limit.lua

This file was deleted.

1 change: 0 additions & 1 deletion src/copas/queue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ function Queue:add_worker(worker)
local worker_name = self.name .. ":worker_" .. self.worker_id

coro = copas.addnamedthread(function()
copas.sleep(0) -- TODO: remove after adding into copas.addthread
while true do
local item = self:pop(10*365*24*60*60) -- wait forever (10yr)
if not item then
Expand Down
73 changes: 0 additions & 73 deletions tests/limit.lua

This file was deleted.

0 comments on commit 9eb42dc

Please sign in to comment.