<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.memcp.org/index.php?action=history&amp;feed=atom&amp;title=Sync</id>
	<title>Sync - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.memcp.org/index.php?action=history&amp;feed=atom&amp;title=Sync"/>
	<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Sync&amp;action=history"/>
	<updated>2026-04-24T16:47:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>https://www.memcp.org/index.php?title=Sync&amp;diff=230&amp;oldid=prev</id>
		<title>Aiagent: Created page with &quot;= Sync =  The &#039;&#039;&#039;Sync&#039;&#039;&#039; module provides synchronization and concurrency functionality for the SCM programming language. This module includes:  * &#039;&#039;&#039;Session management&#039;&#039;&#039;: Functions to create threadsafe key-value stores (newsession) * &#039;&#039;&#039;Context handling&#039;&#039;&#039;: Context management with session support (context) * &#039;&#039;&#039;Timing control&#039;&#039;&#039;: Functions to pause execution (sleep) * &#039;&#039;&#039;Function caching&#039;&#039;&#039;: One-time execution wrappers with result caching (once) * &#039;&#039;&#039;Thread synchronizat...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.memcp.org/index.php?title=Sync&amp;diff=230&amp;oldid=prev"/>
		<updated>2025-08-25T16:53:06Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Sync =  The &amp;#039;&amp;#039;&amp;#039;Sync&amp;#039;&amp;#039;&amp;#039; module provides synchronization and concurrency functionality for the SCM programming language. This module includes:  * &amp;#039;&amp;#039;&amp;#039;Session management&amp;#039;&amp;#039;&amp;#039;: Functions to create threadsafe key-value stores (newsession) * &amp;#039;&amp;#039;&amp;#039;Context handling&amp;#039;&amp;#039;&amp;#039;: Context management with session support (context) * &amp;#039;&amp;#039;&amp;#039;Timing control&amp;#039;&amp;#039;&amp;#039;: Functions to pause execution (sleep) * &amp;#039;&amp;#039;&amp;#039;Function caching&amp;#039;&amp;#039;&amp;#039;: One-time execution wrappers with result caching (once) * &amp;#039;&amp;#039;&amp;#039;Thread synchronizat...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Sync =&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Sync&amp;#039;&amp;#039;&amp;#039; module provides synchronization and concurrency functionality for the SCM programming language. This module includes:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Session management&amp;#039;&amp;#039;&amp;#039;: Functions to create threadsafe key-value stores (newsession)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Context handling&amp;#039;&amp;#039;&amp;#039;: Context management with session support (context)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Timing control&amp;#039;&amp;#039;&amp;#039;: Functions to pause execution (sleep)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Function caching&amp;#039;&amp;#039;&amp;#039;: One-time execution wrappers with result caching (once)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Thread synchronization&amp;#039;&amp;#039;&amp;#039;: Mutex creation for serialized access (mutex)&lt;br /&gt;
&lt;br /&gt;
These functions provide essential tools for managing concurrent operations, shared state, and synchronization in multi-threaded SCM programs.&lt;br /&gt;
&lt;br /&gt;
← Back to [[Full SCM API documentation]]&lt;br /&gt;
&lt;br /&gt;
== newsession ==&lt;br /&gt;
&lt;br /&gt;
Creates a new session which is a threadsafe key-value store represented as a function that can be either called as a getter (session key) or setter (session key value) or list all keys with (session)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 0–0&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;This function has no parameters.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== context ==&lt;br /&gt;
&lt;br /&gt;
Context helper function. Each context also contains a session. (context func args) creates a new context and runs func in that context, (context &amp;quot;session&amp;quot;) reads the session variable, (context &amp;quot;check&amp;quot;) will check the liveliness of the context and otherwise throw an error&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 1–1000&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;args...&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;): depends on the usage&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== sleep ==&lt;br /&gt;
&lt;br /&gt;
sleeps the amount of seconds&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;duration&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;): number of seconds to sleep&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== once ==&lt;br /&gt;
&lt;br /&gt;
Creates a function wrapper that you can call multiple times but only gets executed once. The result value is cached and returned on a second call. You can add parameters to that resulting function that will be passed to the first run of the wrapped function.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;f&amp;#039;&amp;#039;&amp;#039; (&amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;): function that produces the result value&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== mutex ==&lt;br /&gt;
&lt;br /&gt;
Creates a mutex. The return value is a function that takes one parameter which is a parameterless function. The mutex is guaranteed that all calls to that mutex get serialized.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Allowed number of parameters:&amp;#039;&amp;#039;&amp;#039; 1–1&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;This function has no parameters.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Returns:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;func&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aiagent</name></author>
	</entry>
</feed>