Permalink
Browse files

Delay next retrieval until sentinels for the current retrieval finish.

* twittering-mode.el: Delay next asynchronous retrieval until all
sentinels for the current retrieval finish.
(twittering-url-retrieve-async-sentinel): call
`twittering-resolve-url-request' after sentinels finish.
(twittering-url-retrieve-async-clean-up-sentinel): call
`twittering-resolve-url-request' only when the current retrieval
is failed.
  • Loading branch information...
1 parent e96ac82 commit f7cd5295b660b30128fd7a00d4d9fd4373a13daa @cvmat cvmat committed Nov 24, 2010
Showing with 26 additions and 14 deletions.
  1. +10 −0 ChangeLog
  2. +16 −14 twittering-mode.el
View
@@ -1,3 +1,13 @@
+2010-11-25 Tadashi MATSUO <tad@mymail.twin.jp>
+
+ * twittering-mode.el: Delay next asynchronous retrieval until all
+ sentinels for the current retrieval finish.
+ (twittering-url-retrieve-async-sentinel): call
+ `twittering-resolve-url-request' after sentinels finish.
+ (twittering-url-retrieve-async-clean-up-sentinel): call
+ `twittering-resolve-url-request' only when the current retrieval
+ is failed.
+
2010-11-14 Tadashi MATSUO <tad@mymail.twin.jp>
* twittering-mode.el: Fix a bug in registration of a sentinel for
View
@@ -2734,26 +2734,28 @@ this variable specifies. The unit is second.")
(remove uri twittering-internal-url-queue))
(let ((sentinels (gethash uri twittering-url-request-sentinel-hash)))
(when sentinels
- (remhash uri twittering-url-request-sentinel-hash)
- (run-with-idle-timer twittering-url-request-sentinel-delay nil
- (lambda (sentinels uri body)
- (mapc (lambda (func)
- (funcall func uri body))
- sentinels))
- sentinels uri body)
- ;; Without the following nil, it seems that the value of
- ;; `sentinels' is displayed.
- nil))))))
+ (remhash uri twittering-url-request-sentinel-hash))
+ (run-with-idle-timer twittering-url-request-sentinel-delay nil
+ (lambda (sentinels uri body)
+ (mapc (lambda (func) (funcall func uri body))
+ sentinels)
+ ;; Resolve the rest of requests.
+ (setq twittering-url-request-resolving-p nil)
+ (twittering-resolve-url-request))
+ sentinels uri body)
+ ;; Without the following nil, it seems that the value of
+ ;; `sentinels' is displayed.
+ nil)))))
(defun twittering-url-retrieve-async-clean-up-sentinel (proc status connection-info)
(when (memq status '(exit signal closed failed))
(let* ((uri (cdr (assq 'uri connection-info)))
(current (gethash uri twittering-url-data-hash)))
(when (or (null current) (integerp current))
- ;; Increment the counter on failure.
- (puthash uri (1+ (or current 0)) twittering-url-data-hash)))
- (setq twittering-url-request-resolving-p nil)
- (twittering-resolve-url-request)))
+ ;; Increment the counter on failure and then retry retrieval.
+ (puthash uri (1+ (or current 0)) twittering-url-data-hash)
+ (setq twittering-url-request-resolving-p nil)
+ (twittering-resolve-url-request)))))
(defun twittering-url-retrieve-async (url &optional sentinel)
"Retrieve URL asynchronously and call SENTINEL with the retrieved data.

0 comments on commit f7cd529

Please sign in to comment.