Skip to content

Instantly share code, notes, and snippets.

@laurentpetit
Last active August 29, 2015 14:25
Show Gist options
  • Save laurentpetit/5ba6ac5346fb9ee24657 to your computer and use it in GitHub Desktop.
Save laurentpetit/5ba6ac5346fb9ee24657 to your computer and use it in GitHub Desktop.
working on the API part of CCW. First, facilities to have code executed on the UI thread, asynchronously and non blocking, or blocking (synchronously or asynchronously)
;; Which solution would be preferred as an API over SWT Display.syncExec Display.asyncExec ?
;; In java you do this:
;; Display.syncExec( -> ...)
;; Display.asyncExec( -> ...)
(require '[ccw.swt :as swt])
;; O
(swt/sync-exec
... macro body ...)
(swt/async-exec
... macro body ...)
(swt/sync-exec* function)
(swt/async-exec* function)
;; 1
(swt/sync
... macro body ...)
(swt/async
... macro body ...)
(swt/sync* function)
(swt/async* function)
;; 1a
(swt/do-sync
... macro body ...)
(swt/do-async
... macro body ...)
(swt/sync function)
(swt/async function)
;; 2
(swt/ui-sync
... macro body ...)
(swt/ui-async
... macro body ...)
(swt/ui-sync* function)
(swt/ui-async* function)
;; 3
(swt/display-sync
... macro body ...)
(swt/display-async
... macro body ...)
(swt/display-sync* function)
(swt/display-async* function)
;; 4
(swt/do-display-sync
... macro body ...)
(swt/do-display-async
... macro body ...)
(swt/display-sync function)
(swt/display-async function)
;; variants with pending ! to indicate I/O ?
;; O
(swt/sync-exec!
... macro body ...)
(swt/async-exec!
... macro body ...)
(swt/sync-exec!* function)
(swt/async-exec!* function)
;; V1
(swt/sync!
... macro body ...)
(swt/async!
... macro body ...)
(swt/sync!* function)
(swt/async!* function)
;; V1a
(swt/do-sync
... macro body ...)
(swt/doasync
... macro body ...)
(swt/sync! function)
(swt/async! function)
;; V2
(swt/ui-sync!
... macro body ...)
(swt/ui-async!
... macro body ...)
(swt/ui-sync!* function)
(swt/ui-async!* function)
;; V3
(swt/display-sync!
... macro body ...)
(swt/display-async!
... macro body ...)
(swt/display-sync!* function)
(swt/display-async!* function)
;; V4
(swt/do-display-sync ;; or do-display-sync! ?
... macro body ...)
(swt/do-display-async
... macro body ...)
(swt/display-sync! function)
(swt/display-async! function)
@jnizet
Copy link

jnizet commented Jul 24, 2015

I don't know shit about clojure and SWT, but since SWT's Display class uses syncExec and asyncExec, I'd choose the same terminology.

@arichiardi
Copy link

For the functions, I like:

(swt/sync! function)
(swt/async! function)

@arichiardi
Copy link

For macro:

(swt/do-sync
  ... macro body ...)
(swt/do-async
  ... macro body ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment