mirror of https://github.com/deavmi/libsnooze
Compare commits
4 Commits
406023cd6a
...
486446cb6b
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | 486446cb6b | |
Tristan B. Velloza Kildaire | eaaa879959 | |
Tristan B. Velloza Kildaire | a7f5917cc2 | |
Tristan B. Velloza Kildaire | 115cb73e4b |
|
@ -465,7 +465,17 @@ public class Event
|
|||
|
||||
/* Write a single byte to it */
|
||||
byte wakeByte = 69;
|
||||
write(pipeWriteEnd, &wakeByte, 1); // TODO: Collect status and if bad, unlock, throw exception
|
||||
long status = write(pipeWriteEnd, &wakeByte, 1);
|
||||
version(unittest)
|
||||
{
|
||||
writeln("write status: ", status);
|
||||
}
|
||||
|
||||
/* On error writing */
|
||||
if(status == -1)
|
||||
{
|
||||
throw new FatalException(this, FatalError.NOTIFY_FAILURE, "Cannot notify this thread, resource unavailable - event disposed maybe?");
|
||||
}
|
||||
}
|
||||
/* If the thread provided is NOT wait()-ing on this event */
|
||||
else
|
||||
|
@ -724,5 +734,36 @@ unittest
|
|||
|
||||
/* Ensure that we got an exception */
|
||||
assert(foundException !is null);
|
||||
// assert(foundE) TODO: Add further specificty checks
|
||||
assert(cast(FatalException)foundException);
|
||||
|
||||
/* We should not be able to notify */
|
||||
try
|
||||
{
|
||||
event.notify(thread1);
|
||||
assert(false);
|
||||
}
|
||||
catch(FatalException e)
|
||||
{
|
||||
assert(e.getFatalType() == FatalError.NOTIFY_FAILURE);
|
||||
}
|
||||
catch(SnoozeError)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/* We should not be able to notifyAll() */
|
||||
try
|
||||
{
|
||||
event.notifyAll();
|
||||
assert(false);
|
||||
}
|
||||
catch(FatalException e)
|
||||
{
|
||||
assert(e.getFatalType() == FatalError.NOTIFY_FAILURE);
|
||||
}
|
||||
catch(SnoozeError)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue