commit 0247e90cb0f3c7f44f90e9d315b2b4c2706ea936 Spenser Truex <spensertruexonline@gmail.com> 2019-07-03 12:52:46 -0700 Making fresh new bits so they might rot like the last ones.
README.md | 26 -------------------------- README.org | 37 +++++++++++++++++++++++++++++++++++++ code/multithreading.lisp | 5 +++++ code/packages.lisp | 26 +++++++------------------- multi.asd | 11 ++++------- 5 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/README.md b/README.md deleted file mode 100644 index aec3fa3..0000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# lisp-multithreaded-internet -Multithreaded internet for Common Lisp. SSL supported. -# Installation - -clone into `~/common-lisp` or your ASDF directory for your system - -install quicklisp (see the quicklisp website) - -execute: - -``` -> (ql:quickload :bordeaux-threads) -> (ql:quickload :drakma) -> (ql:quickload :uiop) -> (load "FIND LOCATION OF code/multi-internet.asd AND PUT IT HERE") -> (asdf:load-system :multi) -``` -To download websites using multithreading, execute: -``` -> (multi::multiuri "uri1" "uri2" "uri3"...) -``` -For example: -``` -> (multi::multiuri "https://google.com" "https://yahoo.com") -``` -Will download the google homepage and yahoo simultaneously, returning them as strings in a list. \ No newline at end of file diff --git a/README.org b/README.org new file mode 100644 index 0000000..7a18111 --- /dev/null +++ b/README.org @@ -0,0 +1,37 @@ +#+TITLE:Multithreaded Internet +#+AUTHOR: Spenser Truex +#+EMAIL: web@spensertruex.com + +Multithreaded internet for Common Lisp. SSL supported. +* Installation + +Clone into =~/common-lisp/lisp-multithreaded-internet/= or your ASDF directory +for your system (check the value of =asdf:*central-registry*= for more info). + +Install quicklisp (see the [quicklisp website](https://www.quicklisp.org/beta/)). +Execute: +#+BEGIN_SRC lisp +CL-USER> (asdf:load-system :multi) +#+END_SRC +* Usage +To download websites using multithreading, execute: +#+BEGIN_SRC lisp +CL-USER> (multi:uri "uri1" "uri2" "uri3"...) +#+END_SRC +For example: +#+BEGIN_SRC lisp +CL-USER> (multi:uri "https://google.com" "https://yahoo.com") +#+END_SRC +Will download the google homepage and yahoo simultaneously, returning them as +strings in a list. + +* Issues: +Send a pull request if you improve it. +- This could not be simpler, so perhaps none? +- The current implementation is pretty naïve, failing to, for example, timeout. +- Whichever URI takes the longest to download decides how long it takes to + execute. +- It would be nice to have more control over flow in some situations. +- There is virtually no error checking. Even "google.com" wont work without an + HTTP(S) in front of it. + diff --git a/code/multithreading.lisp b/code/multithreading.lisp index c5e87ed..efa1dd1 100644 --- a/code/multithreading.lisp +++ b/code/multithreading.lisp @@ -15,6 +15,11 @@ "Uri should be 'http(s)://domainname.blah.toplevel/blah/blah/blah'" (drakma-no-octets uri)) (defun multiuri (&rest urilist) + "Deprecated function, use `uri' instead!" + (progn (warn "Multiuri is deprecated, use `uri' instead. Consider: +multi::multiuri vs multi:uri. Isn't that a better name?") + (apply #'uri urilist))) +(defun uri (&rest urilist) (let ((lock (gensym)) (list (gensym)) (uri (gensym))) diff --git a/code/packages.lisp b/code/packages.lisp index 1c0ed35..ecffd95 100644 --- a/code/packages.lisp +++ b/code/packages.lisp @@ -1,20 +1,8 @@ -(defpackage :multi-internet-package-loading - (:use :cl :cl-user :asdf) - (:export :defpackage-multi)) -(in-package :multi-internet-package-loading) +(in-package :cl-user) (defpackage :multi - (:use :cl :bordeaux-threads :asdf :cl-user) - (:shadowing-import-from :bordeaux-threads - make-thread - make-lock - join-thread - thread-yield - make-condition-variable - condition-wait - condition-notify - all-threads - thread-alive-p - destroy-thread - interrupt-thread - join-thread) - (:export :getpage)) + (:use :cl) + (:import-from :bordeaux-threads + :make-thread + :make-lock + :join-thread) + (:export :uri)) diff --git a/multi.asd b/multi.asd index 9a033d1..0a73f5d 100644 --- a/multi.asd +++ b/multi.asd @@ -1,12 +1,9 @@ -(defpackage :multi - (:use :cl :cl-user :asdf)) -(in-package :multi) (defsystem :multi :description "Multithreaded internet" - :version "1" - :author "Spenser Truex <spensertruexonline@gmail.com>" - :license "Free" + :version "0.0.2" + :author "Spenser Truex <web@spensertruex.com>" + :license "GNU GPL v3" :depends-on (:drakma :uiop :bordeaux-threads) :serial t :components ((:file "packages") - (:file "multithreading"))) + (:file "multithreading")))