Concept Framework 2.2 documentation Contents | Index

standard.lib.shared.share_lock

Name Version Deprecated
share_lock version 1.0 no

Prototype:
boolean share_lock(number share_handle[, bool blocking=false])

Parameters:
share_handle      the shared memory handle as returned by share_create or share_open.
blocking      (optional parameter, default is false). If set to true, this function will wait if the shared memory segment is locked by another process until it will be unlocked.

Description:
Locks the access to a shared memory segment for the current process. To unlock, call share_unlock.

Example:
import standard.lib.shared

class Main {
	function Main() {
		var ctx=share_open(123);
		echo ctx;
		share_lock(ctx);
		for (var i=0;i<200000;i++) {
			share_set(ctx,""+i);
		}
		echo "done lock";
		echo "SH:"+share_unlock(ctx)+"\n";
		echo "SH:"+share_unlock(ctx)+"\n";
		echo share_get(ctx);
		echo "\n";
		echo typeof this;
		while (1) {
			echo ""+share_link_count(ctx)+"\r";
		}
	}
}

Returns:
Returns true if succeeded, false if failed (already locked by another process).

Documented by Eduard Suica, generation time: Sun Jan 27 18:15:17 2013 GMT(c)2013 Devronium Applications