libsnooze 0.3.3

A wait/notify mechanism for D


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

<p align="center"> <img src="branding/logo.png" width=220> </p>


<h1 align="center">libsnooze</h1>

<h3 align="center"><i><b>A wait/notify mechanism for D</i></b></h3>



API

To see the full documentation (which is always up-to-date) check it out on DUB.

Usage

Importing issues

Currently importing just with import libsnooze is broken, we recommend you import as follows:

import libsnooze.clib;
import libsnooze;

Which should build!

Example

Firstly we create an Event which is something that can be notified or awaited on. This is simply accomplished as follows:

Event myEvent = new Event();

Now let's create a thread which consumes myEvent and waits on it:

class TestThread : Thread
{
    private Event event;

    this(Event event)
    {
        super(&worker);
        this.event = event;
    }

    public void worker()
    {
        writeln("("~to!(string)(Thread.getThis().id())~") Thread is waiting...");
        event.wait();
        writeln("("~to!(string)(Thread.getThis().id())~") Thread is waiting... [done]");
    }
}

TestThread thread1 = new TestThread(event);
thread1.start();

Now on the main thread we can do the following to wakeup waiting threads:

/* Wake up all sleeping on this event */
event.notifyAll();
Authors:
  • Tristan B. Velloza Kildaire
Dependencies:
none
Versions:
0.3.3 2023-Mar-19
0.3.2 2023-Mar-19
0.3.1 2023-Mar-19
0.3.0 2023-Mar-10
0.2.9 2023-Feb-26
Show all 20 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.0
Short URL:
libsnooze.dub.pm