Fix LFBTextBuffer GetChar starting worker thread when paused.

This commit is contained in:
Jonas 'Sortie' Termansen 2018-07-24 23:02:36 +02:00
parent 4a33c460f6
commit 5be7b52422
2 changed files with 9 additions and 4 deletions

View File

@ -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 ) if ( invalidated )
{ {
@ -369,12 +369,15 @@ void LFBTextBuffer::IssueCommand(TextBufferCmd* cmd)
RenderRange(render_from, render_to); RenderRange(render_from, render_to);
return; return;
} }
ScopedLock lock(&queue_lock); if ( !already_locked )
kthread_mutex_lock(&queue_lock);
while ( queue_used == queue_length ) while ( queue_used == queue_length )
kthread_cond_wait(&queue_not_full, &queue_lock); kthread_cond_wait(&queue_not_full, &queue_lock);
if ( !queue_used ) if ( !queue_used )
kthread_cond_signal(&queue_not_empty); kthread_cond_signal(&queue_not_empty);
queue[(queue_offset + queue_used++) % queue_length] = *cmd; queue[(queue_offset + queue_used++) % queue_length] = *cmd;
if ( !already_locked )
kthread_mutex_unlock(&queue_lock);
} }
bool LFBTextBuffer::StopRendering() bool LFBTextBuffer::StopRendering()
@ -383,8 +386,10 @@ bool LFBTextBuffer::StopRendering()
return false; return false;
TextBufferCmd cmd; TextBufferCmd cmd;
cmd.type = TEXTBUFCMD_PAUSE; cmd.type = TEXTBUFCMD_PAUSE;
IssueCommand(&cmd);
ScopedLock lock(&queue_lock); ScopedLock lock(&queue_lock);
if ( queue_is_paused )
return false;
IssueCommand(&cmd, true);
while ( !queue_is_paused ) while ( !queue_is_paused )
kthread_cond_wait(&queue_paused, &queue_lock); kthread_cond_wait(&queue_paused, &queue_lock);
return true; return true;

View File

@ -98,7 +98,7 @@ private:
void DoScroll(ssize_t off, TextChar entry); void DoScroll(ssize_t off, TextChar entry);
void DoMove(TextPos to, TextPos from, size_t numchars); void DoMove(TextPos to, TextPos from, size_t numchars);
void DoFill(TextPos from, TextPos to, TextChar fillwith); void DoFill(TextPos from, TextPos to, TextChar fillwith);
void IssueCommand(TextBufferCmd* cmd); void IssueCommand(TextBufferCmd* cmd, bool already_locked = false);
bool StopRendering(); bool StopRendering();
void ResumeRendering(); void ResumeRendering();
bool IsCommandIdempotent(const TextBufferCmd* cmd) const; bool IsCommandIdempotent(const TextBufferCmd* cmd) const;