SyncSemaphore::__construct

(PECL sync >= 1.0.0)

SyncSemaphore::__constructConstructs a new SyncSemaphore object

Beschreibung

public SyncSemaphore::__construct(string $name = ?, int $initialval = 1, bool $autounlock = true)

Constructs a named or unnamed semaphore.

Parameter-Liste

name

The name of the semaphore if this is a named semaphore object.

Hinweis:

If the name already exists, it must be able to be opened by the current user that the process is running as or an exception will be thrown with a meaningless error message.

initialval

The initial value of the semaphore. This is the number of locks that may be obtained.

autounlock

Specifies whether or not to automatically unlock the semaphore at the conclusion of the PHP script.

Warnung

If an object is: A named semaphore with an autounlock of false, the object is locked, and the PHP script concludes before the object is unlocked, then the underlying semaphore will end up in an inconsistent state.

Rückgabewerte

The new SyncSemaphore object.

Fehler/Exceptions

An exception is thrown if the semaphore cannot be created or opened.

Beispiele

Beispiel #1 SyncSemaphore::__construct() example

<?php
$semaphore 
= new SyncSemaphore("LimitedResource_2clients"2);

if (!
$semaphore->lock(3000))
{
    echo 
"Unable to lock semaphore.";

    exit();
}

/* ... */

$semaphore->unlock();
?>

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

+27736918822 WIN CASINO & LOTTO- LUCK SPELLS CASTER -ROMANIA

Casino spells to help you make more money. Get luck at the casino & gambling with casino spells, bingo casino spells, Roulette winning spells, bla ...

Geschrieben von DRMAMAJANICE am 27.06.2026 03:26:52
Forum: Ankündigungen
+27736918822】Best traditional healer - How to cast a miscarriage spell in Canberra

Has your husband impregnanted a lady , do you wish to revenge back Not every pregnancy is wanted depending on the circumstances, it might be on yo ...

Geschrieben von DRMAMAJANICE am 27.06.2026 03:25:58
Forum: Ankündigungen
+27736918822 how to choose the winning lotto numbers- best lottery spells caster

Best lottery spells caster Powerful lottery spells to make you win millions jackpot cash Casting this lottery spell will be one of the biggest ste ...

Geschrieben von DRMAMAJANICE am 27.06.2026 03:25:01
Forum: Ankündigungen
【+27736918822】 TIME TRAVEL SPELLS ON REVENGE ON SOME ONE West Virginia, Wisconsin

There are times when people really annoy us, betray us or do so many dubious things to us. There are times when people wrong you and you wish you ...

Geschrieben von DRMAMAJANICE am 27.06.2026 03:24:22
Forum: Ankündigungen