Commit 5be7b524 authored by Jonas Termansen's avatar Jonas Termansen

Fix LFBTextBuffer GetChar starting worker thread when paused.

parent 4a33c460
......@@ -348,7 +348,7 @@ void LFBTextBuffer::RenderRange(TextPos from, TextPos to)
}
}
void LFBTextBuffer::IssueCommand(TextBufferCmd* cmd)
void LFBTextBuffer::IssueCommand(TextBufferCmd* cmd, bool already_locked)
{
if ( invalidated )
{
......@@ -369,12 +369,15 @@ void LFBTextBuffer::IssueCommand(TextBufferCmd* cmd)
RenderRange(render_from, render_to);
return;
}
ScopedLock lock(&queue_lock);
if ( !already_locked )
kthread_mutex_lock(&queue_lock);
while ( queue_used == queue_length )
kthread_cond_wait(&queue_not_full, &queue_lock);
if ( !queue_used )
kthread_cond_signal(&queue_not_empty);
queue[(queue_offset + queue_used++) % queue_length] = *cmd;
if ( !already_locked )
kthread_mutex_unlock(&queue_lock);
}
bool LFBTextBuffer::StopRendering()
......@@ -383,8 +386,10 @@ bool LFBTextBuffer::StopRendering()
return false;
TextBufferCmd cmd;
cmd.type = TEXTBUFCMD_PAUSE;
IssueCommand(&cmd);
ScopedLock lock(&queue_lock);
if ( queue_is_paused )
return false;
IssueCommand(&cmd, true);
while ( !queue_is_paused )
kthread_cond_wait(&queue_paused, &queue_lock);
return true;
......
......@@ -98,7 +98,7 @@ private:
void DoScroll(ssize_t off, TextChar entry);
void DoMove(TextPos to, TextPos from, size_t numchars);
void DoFill(TextPos from, TextPos to, TextChar fillwith);
void IssueCommand(TextBufferCmd* cmd);
void IssueCommand(TextBufferCmd* cmd, bool already_locked = false);
bool StopRendering();
void ResumeRendering();
bool IsCommandIdempotent(const TextBufferCmd* cmd) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment