|
1366 | 1366 | [] (clojure.lang.Agent/releasePendingSends)) |
1367 | 1367 |
|
1368 | 1368 | (defn add-watch |
1369 | | - "Experimental. |
| 1369 | + "Alpha - subject to change. |
1370 | 1370 | Adds a watch function to an agent/atom/var/ref reference. The watch |
1371 | 1371 | fn must be a fn of 4 args: a key, the reference, its old-state, its |
1372 | 1372 | new-state. Whenever the reference's state might have been changed, |
|
1383 | 1383 | [#^clojure.lang.IRef reference key fn] (.addWatch reference key fn)) |
1384 | 1384 |
|
1385 | 1385 | (defn remove-watch |
1386 | | - "Experimental. |
| 1386 | + "Alpha - subject to change. |
1387 | 1387 | Removes a watch (set by add-watch) from a reference" |
1388 | 1388 | [#^clojure.lang.IRef reference key] |
1389 | 1389 | (.removeWatch reference key)) |
1390 | 1390 |
|
1391 | | -(defn add-watcher |
1392 | | - "Experimental. |
1393 | | - Adds a watcher to an agent/atom/var/ref reference. The watcher must |
1394 | | - be an Agent, and the action a function of the agent's state and one |
1395 | | - additional arg, the reference. Whenever the reference's state |
1396 | | - changes, any registered watchers will have their actions |
1397 | | - sent. send-type must be one of :send or :send-off. The actions will |
1398 | | - be sent after the reference's state is changed. Var watchers are |
1399 | | - triggered only by root binding changes, not thread-local set!s" |
1400 | | - [#^clojure.lang.IRef reference send-type watcher-agent action-fn] |
1401 | | - (add-watch reference watcher-agent |
1402 | | - (fn [watcher-agent reference old-state new-state] |
1403 | | - (when-not (identical? old-state new-state) |
1404 | | - ((if (= send-type :send-off) send-off send) |
1405 | | - watcher-agent action-fn reference))))) |
1406 | | - |
1407 | | -(defn remove-watcher |
1408 | | - "Experimental. |
1409 | | - Removes a watcher (set by add-watcher) from a reference" |
1410 | | - [reference watcher-agent] |
1411 | | - (remove-watch reference watcher-agent)) |
1412 | 1391 |
|
1413 | 1392 | (defn agent-errors |
1414 | 1393 | "Returns a sequence of the exceptions thrown during asynchronous |
|
4592 | 4571 | "-SNAPSHOT"))) |
4593 | 4572 |
|
4594 | 4573 | (defn promise |
4595 | | - "Experimental. |
| 4574 | + "Alpha - subject to change. |
4596 | 4575 | Returns a promise object that can be read with deref/@, and set, |
4597 | 4576 | once only, with deliver. Calls to deref/@ prior to delivery will |
4598 | 4577 | block. All subsequent derefs will return the same delivered value |
|
4611 | 4590 | (throw (IllegalStateException. "Multiple deliver calls to a promise")))))))) |
4612 | 4591 |
|
4613 | 4592 | (defn deliver |
4614 | | - "Experimental. |
| 4593 | + "Alpha - subject to change. |
4615 | 4594 | Delivers the supplied value to the promise, releasing any pending |
4616 | 4595 | derefs. A subsequent call to deliver on a promise will throw an exception." |
4617 | 4596 | [promise val] (promise val)) |
4618 | 4597 |
|
4619 | 4598 | ;;;;;;;;;;;;;;;;;;;;; editable collections ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4620 | 4599 | (defn transient |
4621 | | - "Returns a new, transient version of the collection, in constant time." |
| 4600 | + "Alpha - subject to change. |
| 4601 | + Returns a new, transient version of the collection, in constant time." |
4622 | 4602 | [#^clojure.lang.IEditableCollection coll] |
4623 | 4603 | (.asTransient coll)) |
4624 | 4604 |
|
4625 | 4605 | (defn persistent! |
4626 | | - "Returns a new, persistent version of the transient collection, in |
| 4606 | + "Alpha - subject to change. |
| 4607 | + Returns a new, persistent version of the transient collection, in |
4627 | 4608 | constant time. The transient collection cannot be used after this |
4628 | 4609 | call, any such use will throw an exception." |
4629 | 4610 | [#^clojure.lang.ITransientCollection coll] |
4630 | 4611 | (.persistent coll)) |
4631 | 4612 |
|
4632 | 4613 | (defn conj! |
4633 | | - "Adds x to the transient collection, and return coll. The 'addition' |
| 4614 | + "Alpha - subject to change. |
| 4615 | + Adds x to the transient collection, and return coll. The 'addition' |
4634 | 4616 | may happen at different 'places' depending on the concrete type." |
4635 | 4617 | [#^clojure.lang.ITransientCollection coll x] |
4636 | 4618 | (.conj coll x)) |
4637 | 4619 |
|
4638 | 4620 | (defn assoc! |
4639 | | - "When applied to a transient map, adds mapping of key(s) to |
| 4621 | + "Alpha - subject to change. |
| 4622 | + When applied to a transient map, adds mapping of key(s) to |
4640 | 4623 | val(s). When applied to a transient vector, sets the val at index. |
4641 | 4624 | Note - index must be <= (count vector). Returns coll." |
4642 | 4625 | ([#^clojure.lang.ITransientAssociative coll key val] (.assoc coll key val)) |
|
4647 | 4630 | ret)))) |
4648 | 4631 |
|
4649 | 4632 | (defn dissoc! |
4650 | | - "Returns a transient map that doesn't contain a mapping for key(s)." |
| 4633 | + "Alpha - subject to change. |
| 4634 | + Returns a transient map that doesn't contain a mapping for key(s)." |
4651 | 4635 | ([#^clojure.lang.ITransientMap map key] (.without map key)) |
4652 | 4636 | ([#^clojure.lang.ITransientMap map key & ks] |
4653 | 4637 | (let [ret (.without map key)] |
|
4656 | 4640 | ret)))) |
4657 | 4641 |
|
4658 | 4642 | (defn pop! |
4659 | | - "Removes the last item from a transient vector. If |
| 4643 | + "Alpha - subject to change. |
| 4644 | + Removes the last item from a transient vector. If |
4660 | 4645 | the collection is empty, throws an exception. Returns coll" |
4661 | 4646 | [#^clojure.lang.ITransientVector coll] |
4662 | 4647 | (.pop coll)) |
4663 | 4648 |
|
4664 | 4649 | (defn disj! |
4665 | | - "disj[oin]. Returns a transient set of the same (hashed/sorted) type, that |
| 4650 | + "Alpha - subject to change. |
| 4651 | + disj[oin]. Returns a transient set of the same (hashed/sorted) type, that |
4666 | 4652 | does not contain key(s)." |
4667 | 4653 | ([set] set) |
4668 | 4654 | ([#^clojure.lang.ITransientSet set key] |
|
0 commit comments