Skip to content

Commit

Permalink
Future
Browse files Browse the repository at this point in the history
- Lock mutex, then wait on condition variable, when reawakening we have lock, then unlock it
  • Loading branch information
deavmi committed Oct 1, 2023
1 parent 55e5ba9 commit f0b2a10
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions source/guillotine/future.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,18 @@ public final class Future
// the FutureTask sets to RUNNING and when our main thread
// calls await() can have it pickup on the NOT_STARTED case)
else
{
bool doneYet = false;
while(!doneYet)
{
try
{
signal.wait();
doneYet = true;
}
catch(SyncError e)
{
// TODO: What should we do here?
}
}
{
// Lock mutex
this.mutex.lock();

// Wait on condition variable
this.signal.wait();

// TODO: Add syncerror checking?

// Unlock mutex
this.mutex.unlock();


// If we had an error then throw it
if(this.state == State.ERRORED)
Expand Down

0 comments on commit f0b2a10

Please sign in to comment.