Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

core.sync.event

The event module provides a primitive for lightweight signaling of other threads (emulating Windows events on Posix)
License:
Distributed under theBoost Software License 1.0. (See accompanying file LICENSE)
Authors:
Rainer Schuetze

Sourcecore/sync/event.d

structEvent;
represents an event. Clients of an event are suspended while waiting for the event to be "signaled".
Implemented usingpthread_mutex andpthread_condition on Posix andCreateEvent andSetEvent on Windows.
import core.sync.event, core.thread, std.file;struct ProcessFile{    ThreadGroup group;Event event;void[] buffer;void doProcess()    {        event.wait();// process buffer    }void process(string filename)    {        event.initialize(true,false);        group =new ThreadGroup;for (int i = 0; i < 10; ++i)            group.create(&doProcess);        buffer = std.file.read(filename);        event.setIfInitialized();        group.joinAll();        event.terminate();    }}
nothrow @nogc this(boolmanualReset, boolinitialState);
Creates an event object.
Parameters:
boolmanualResetthe state of the event is not reset automatically after resuming waiting clients
boolinitialStateinitial state of the signal
nothrow @nogc voidinitialize(boolmanualReset, boolinitialState);
Initializes an event object. Does nothing if the event is already initialized.
Parameters:
boolmanualResetthe state of the event is not reset automatically after resuming waiting clients
boolinitialStateinitial state of the signal
nothrow @nogc voidterminate();
deinitialize event. Does nothing if the event is not initialized. There must not be threads currently waiting for the event to be signaled.
nothrow @nogc voidsetIfInitialized();
Set the event to "signaled", so that waiting clients are resumed
nothrow @nogc voidreset();
Reset the event manually
nothrow @nogc boolwait();
Wait for the event to be signaled without timeout.
Returns:
true if the event is in signaled state,false if the event is uninitialized or another error occured
nothrow @nogc boolwait(Durationtmout);
Wait for the event to be signaled with timeout.
Parameters:
Durationtmoutthe maximum time to wait
Returns:
true if the event is in signaled state,false if the event was nonsignaled for the given time or the event is uninitialized or another error occured
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 21:24:19 2026

[8]ページ先頭

©2009-2026 Movatter.jp