mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 10:40:20 +03:00
Fix compilation issues with older C++ versions.
This commit is contained in:
@@ -222,7 +222,7 @@ class TerminalController final : public std::enable_shared_from_this<TerminalCon
|
||||
TerminalColorPalette palette );
|
||||
|
||||
void start();
|
||||
void enqueue( Command&& command );
|
||||
bool enqueue( Command&& command );
|
||||
void workerLoop();
|
||||
void processCommands();
|
||||
void processCommand( Command&& command );
|
||||
@@ -238,7 +238,8 @@ class TerminalController final : public std::enable_shared_from_this<TerminalCon
|
||||
std::deque<Command> mCommands;
|
||||
std::mutex mEventMutex;
|
||||
std::deque<Event> mEvents;
|
||||
std::atomic<std::shared_ptr<const TerminalSnapshot>> mPublishedSnapshot;
|
||||
mutable std::mutex mPublishedSnapshotMutex;
|
||||
std::shared_ptr<const TerminalSnapshot> mPublishedSnapshot;
|
||||
std::atomic<bool> mShutdownRequested{ false };
|
||||
std::atomic<Uint64> mNextScrollCommand{ 0 };
|
||||
};
|
||||
|
||||
@@ -277,16 +277,18 @@ void TerminalController::shutdown() {
|
||||
mWorker.join();
|
||||
}
|
||||
|
||||
void TerminalController::enqueue( Command&& command ) {
|
||||
if ( mShutdownRequested.load( std::memory_order_acquire ) )
|
||||
return;
|
||||
bool TerminalController::enqueue( Command&& command ) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( mCommandMutex );
|
||||
|
||||
if ( mShutdownRequested.load( std::memory_order_relaxed ) )
|
||||
return;
|
||||
return false;
|
||||
|
||||
mCommands.emplace_back( std::move( command ) );
|
||||
}
|
||||
|
||||
mCommandCondition.notify_one();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TerminalController::write( std::string data, bool mayEcho ) {
|
||||
@@ -310,10 +312,11 @@ void TerminalController::scrollDown( int amount ) {
|
||||
}
|
||||
|
||||
Uint64 TerminalController::scrollTo( int position ) {
|
||||
if ( mShutdownRequested.load( std::memory_order_acquire ) )
|
||||
return 0;
|
||||
const Uint64 commandId = mNextScrollCommand.fetch_add( 1, std::memory_order_relaxed ) + 1;
|
||||
enqueue( ScrollCommand{ position, 0, commandId } );
|
||||
|
||||
if ( !enqueue( ScrollCommand{ position, 0, commandId } ) )
|
||||
return 0;
|
||||
|
||||
return commandId;
|
||||
}
|
||||
|
||||
@@ -379,7 +382,8 @@ void TerminalController::restart( PtyPtr&& pty, ProcPtr&& process ) {
|
||||
}
|
||||
|
||||
std::shared_ptr<const TerminalSnapshot> TerminalController::snapshot() const {
|
||||
return mPublishedSnapshot.load( std::memory_order_acquire );
|
||||
std::lock_guard<std::mutex> lock( mPublishedSnapshotMutex );
|
||||
return mPublishedSnapshot;
|
||||
}
|
||||
|
||||
std::optional<std::string>
|
||||
@@ -426,7 +430,10 @@ void TerminalController::enqueueEvent( Event event, bool coalescable ) {
|
||||
|
||||
void TerminalController::publishSnapshot( std::shared_ptr<const TerminalSnapshot> snapshot ) {
|
||||
const Uint64 generation = snapshot->generation;
|
||||
mPublishedSnapshot.store( std::move( snapshot ), std::memory_order_release );
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( mPublishedSnapshotMutex );
|
||||
mPublishedSnapshot = std::move( snapshot );
|
||||
}
|
||||
Event event{ EventType::SnapshotReady };
|
||||
event.generation = generation;
|
||||
enqueueEvent( std::move( event ), true );
|
||||
|
||||
Reference in New Issue
Block a user