View source code
Display the source code in core/sync/event.d from which this
page was generated on github.
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 using
local clone.
Struct core.sync.event.Event
represents an event. Clients of an event are suspended while waiting for the event to be "signaled".
struct Event
;
Implemented using pthread_mutex
and pthread_condition
on Posix and
CreateEvent
and SetEvent
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 = read(filename);
event .set();
group .joinAll();
event .terminate();
}
}
Constructors
Name | Description |
---|---|
this
(manualReset, initialState)
|
Creates an event object. |
Methods
Name | Description |
---|---|
initialize
(manualReset, initialState)
|
Initializes an event object. Does nothing if the event is already initialized. |
reset
()
|
Reset the event manually |
set
()
|
Set the event to "signaled", so that waiting clients are resumed |
terminate
()
|
deinitialize event. Does nothing if the event is not initialized. There must not be threads currently waiting for the event to be signaled. |
wait
()
|
Wait for the event to be signaled without timeout. |
wait
(tmout)
|
Wait for the event to be signaled with timeout. |
Authors
Rainer Schuetze
License
Distributed under the Boost Software License 1.0. (See accompanying file LICENSE)
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.