Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
create-subscriber.js96 linesDownload Raw Back to reactivity
1import { get, tick, untrack } from '../internal/client/runtime.js';2import { effect_tracking, render_effect } from '../internal/client/reactivity/effects.js';3import { source, increment } from '../internal/client/reactivity/sources.js';4import { tag } from '../internal/client/dev/tracing.js';5import { DEV } from 'esm-env';6import { queue_micro_task } from '../internal/client/dom/task.js';7 8/**9 * Returns a `subscribe` function that integrates external event-based systems with Svelte's reactivity.10 * It's particularly useful for integrating with web APIs like `MediaQuery`, `IntersectionObserver`, or `WebSocket`.11 *12 * If `subscribe` is called inside an effect (including indirectly, for example inside a getter),13 * the `start` callback will be called with an `update` function. Whenever `update` is called, the effect re-runs.14 *15 * If `start` returns a cleanup function, it will be called when the effect is destroyed.16 *17 * If `subscribe` is called in multiple effects, `start` will only be called once as long as the effects18 * are active, and the returned teardown function will only be called when all effects are destroyed.19 *20 * It's best understood with an example. Here's an implementation of [`MediaQuery`](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery):21 *22 * ```js23 * import { createSubscriber } from 'svelte/reactivity';24 * import { on } from 'svelte/events';25 *26 * export class MediaQuery {27 * 	#query;28 * 	#subscribe;29 *30 * 	constructor(query) {31 * 		this.#query = window.matchMedia(`(${query})`);32 *33 * 		this.#subscribe = createSubscriber((update) => {34 * 			// when the `change` event occurs, re-run any effects that read `this.current`35 * 			const off = on(this.#query, 'change', update);36 *37 * 			// stop listening when all the effects are destroyed38 * 			return () => off();39 * 		});40 * 	}41 *42 * 	get current() {43 * 		// This makes the getter reactive, if read in an effect44 * 		this.#subscribe();45 *46 * 		// Return the current state of the query, whether or not we're in an effect47 * 		return this.#query.matches;48 * 	}49 * }50 * ```51 * @param {(update: () => void) => (() => void) | void} start52 * @since 5.7.053 */54export function createSubscriber(start) {55	let subscribers = 0;56	let version = source(0);57	/** @type {(() => void) | void} */58	let stop;59 60	if (DEV) {61		tag(version, 'createSubscriber version');62	}63 64	return () => {65		if (effect_tracking()) {66			get(version);67 68			render_effect(() => {69				if (subscribers === 0) {70					stop = untrack(() => start(() => increment(version)));71				}72 73				subscribers += 1;74 75				return () => {76					queue_micro_task(() => {77						// Only count down after a microtask, else we would reach 0 before our own render effect reruns,78						// but reach 1 again when the tick callback of the prior teardown runs. That would mean we79						// re-subcribe unnecessarily and create a memory leak because the old subscription is never cleaned up.80						subscribers -= 1;81 82						if (subscribers === 0) {83							stop?.();84							stop = undefined;85							// Increment the version to ensure any dependent deriveds are marked dirty when the subscription is picked up again later.86							// If we didn't do this then the comparison of write versions would determine that the derived has a later version than87							// the subscriber, and it would not be re-run.88							increment(version);89						}90					});91				};92			});93		}94	};95}96 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai