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