diff options
| author | David Barksdale <amatus.amongus@gmail.com> | 2011-11-16 23:03:47 -0600 |
|---|---|---|
| committer | David Barksdale <amatus.amongus@gmail.com> | 2011-11-16 23:03:47 -0600 |
| commit | aedcc3d2fe77779b1b1ff52fb230b5dfe3c9240e (patch) | |
| tree | ea15c21b9acba4d55546135e32ea45de046429b7 /src/clojure | |
| parent | 5984e1d3b402cbae0ccd0f279012bf0b53806b18 (diff) | |
Let's try using the state monad for writing into ByteBuffers.
Diffstat (limited to 'src/clojure')
| -rw-r--r-- | src/clojure/foofs/fuse/bytebuffer.clj | 14 | ||||
| -rw-r--r-- | src/clojure/foofs/fuse/protocol.clj | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/clojure/foofs/fuse/bytebuffer.clj b/src/clojure/foofs/fuse/bytebuffer.clj index 2ca6f92..0e4edaf 100644 --- a/src/clojure/foofs/fuse/bytebuffer.clj +++ b/src/clojure/foofs/fuse/bytebuffer.clj @@ -30,3 +30,17 @@ [(.and (biginteger 0xffffffffffffffff) (biginteger (.getLong buffer2))) buffer2]))) +(defn write-int16 + [x] + (fn write-int16-m + [buffer] + (.putShort buffer x) + nil)) + +(defn write-int32 + [x] + (fn write-int32-m + [buffer] + (.putInt buffer x) + nil)) + diff --git a/src/clojure/foofs/fuse/protocol.clj b/src/clojure/foofs/fuse/protocol.clj index 9792846..bc686c1 100644 --- a/src/clojure/foofs/fuse/protocol.clj +++ b/src/clojure/foofs/fuse/protocol.clj @@ -79,3 +79,14 @@ flags parse-opaque32] (init-in. major minor max-readahead flags))) +(defn write-init-out + [init-out] + (domonad state-m + [_ (format-int32 (:major init-out)) + _ (format-int32 (:minor init-out)) + _ (format-int32 (:max-readahead init-out)) + _ (format-int16 (:max-background init-out)) + _ (format-int16 (:congestion-threshold init-out)) + _ (format-int32 (:max-write init-out))] + nil)) + |
