lib: Pass jobs to barrier::Thread as std::function
This commit is contained in:
parent
53356697d9
commit
d2c106db53
|
@ -34,7 +34,6 @@
|
|||
|
||||
#if SYSAPI_WIN32
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@ -229,8 +228,7 @@ App::handleIpcMessage(const Event& e, void*)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
App::runEventsLoop(void*)
|
||||
void App::run_events_loop()
|
||||
{
|
||||
m_events->loop();
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ private:
|
|||
protected:
|
||||
void initIpcClient();
|
||||
void cleanupIpcClient();
|
||||
void runEventsLoop(void*);
|
||||
void run_events_loop();
|
||||
|
||||
IArchTaskBarReceiver* m_taskBarReceiver;
|
||||
bool m_suspended;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "base/TMethodEventJob.h"
|
||||
#include "base/log_outputters.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "common/Version.h"
|
||||
|
||||
|
@ -465,10 +464,7 @@ ClientApp::mainLoop()
|
|||
|
||||
#if defined(MAC_OS_X_VERSION_10_7)
|
||||
|
||||
Thread thread(
|
||||
new TMethodJob<ClientApp>(
|
||||
this, &ClientApp::runEventsLoop,
|
||||
NULL));
|
||||
Thread thread([this](){ run_events_loop(); });
|
||||
|
||||
// wait until carbon loop is ready
|
||||
OSXScreen* screen = dynamic_cast<OSXScreen*>(
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace barrier { class Screen; }
|
|||
class Event;
|
||||
class Client;
|
||||
class NetworkAddress;
|
||||
class Thread;
|
||||
class ClientArgs;
|
||||
|
||||
class ClientApp : public App {
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "base/EventQueue.h"
|
||||
#include "base/log_outputters.h"
|
||||
#include "base/FunctionEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
|
@ -797,10 +796,7 @@ ServerApp::mainLoop()
|
|||
|
||||
#if defined(MAC_OS_X_VERSION_10_7)
|
||||
|
||||
Thread thread(
|
||||
new TMethodJob<ServerApp>(
|
||||
this, &ServerApp::runEventsLoop,
|
||||
NULL));
|
||||
Thread thread([this](){ run_events_loop(); });
|
||||
|
||||
// wait until carbon loop is ready
|
||||
OSXScreen* screen = dynamic_cast<OSXScreen*>(
|
||||
|
|
|
@ -42,14 +42,13 @@ bool StreamChunker::s_interruptFile = false;
|
|||
Mutex* StreamChunker::s_interruptMutex = NULL;
|
||||
|
||||
void
|
||||
StreamChunker::sendFile(
|
||||
char* filename,
|
||||
StreamChunker::sendFile(const char* filename,
|
||||
IEventQueue* events,
|
||||
void* eventTarget)
|
||||
{
|
||||
s_isChunkingFile = true;
|
||||
|
||||
std::fstream file(static_cast<char*>(filename), std::ios::in | std::ios::binary);
|
||||
std::fstream file(filename, std::ios::in | std::ios::binary);
|
||||
|
||||
if (!file.is_open()) {
|
||||
throw runtime_error("failed to open file");
|
||||
|
|
|
@ -25,10 +25,7 @@ class Mutex;
|
|||
|
||||
class StreamChunker {
|
||||
public:
|
||||
static void sendFile(
|
||||
char* filename,
|
||||
IEventQueue* events,
|
||||
void* eventTarget);
|
||||
static void sendFile(const char* filename, IEventQueue* events, void* eventTarget);
|
||||
static void sendClipboard(
|
||||
String& data,
|
||||
size_t size,
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "net/SocketMultiplexer.h"
|
||||
#include "arch/XArch.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/log_outputters.h"
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* barrier -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2002 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file LICENSE that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "base/FunctionJob.h"
|
||||
|
||||
//
|
||||
// FunctionJob
|
||||
//
|
||||
|
||||
FunctionJob::FunctionJob(void (*func)(void*), void* arg) :
|
||||
m_func(func),
|
||||
m_arg(arg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
FunctionJob::~FunctionJob()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
FunctionJob::run()
|
||||
{
|
||||
if (m_func != NULL) {
|
||||
m_func(m_arg);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* barrier -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2002 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file LICENSE that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base/IJob.h"
|
||||
|
||||
//! Use a function as a job
|
||||
/*!
|
||||
A job class that invokes a function.
|
||||
*/
|
||||
class FunctionJob : public IJob {
|
||||
public:
|
||||
//! run() invokes \c func(arg)
|
||||
FunctionJob(void (*func)(void*), void* arg = NULL);
|
||||
virtual ~FunctionJob();
|
||||
|
||||
// IJob overrides
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
void (*m_func)(void*);
|
||||
void* m_arg;
|
||||
};
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* barrier -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2002 Chris Schoeneman
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* found in the file LICENSE that should have accompanied this file.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "IJob.h"
|
||||
|
||||
//! Use a function as a job
|
||||
/*!
|
||||
A job class that invokes a member function.
|
||||
*/
|
||||
template <class T>
|
||||
class TMethodJob : public IJob {
|
||||
public:
|
||||
//! run() invokes \c object->method(arg)
|
||||
TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
|
||||
virtual ~TMethodJob();
|
||||
|
||||
// IJob overrides
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
T* m_object;
|
||||
void (T::*m_method)(void*);
|
||||
void* m_arg;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
TMethodJob<T>::TMethodJob(T* object, void (T::*method)(void*), void* arg) :
|
||||
m_object(object),
|
||||
m_method(method),
|
||||
m_arg(arg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
TMethodJob<T>::~TMethodJob()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
void
|
||||
TMethodJob<T>::run()
|
||||
{
|
||||
if (m_object != NULL) {
|
||||
(m_object->*m_method)(m_arg);
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include "base/log_outputters.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/String.h"
|
||||
#include "io/filesystem.h"
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
@ -760,9 +759,7 @@ void
|
|||
Client::onFileRecieveCompleted()
|
||||
{
|
||||
if (isReceivedFileSizeValid()) {
|
||||
m_writeToDropDirThread = new Thread(
|
||||
new TMethodJob<Client>(
|
||||
this, &Client::writeToDropDirThread));
|
||||
m_writeToDropDirThread = new Thread([this](){ write_to_drop_dir_thread(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,8 +769,7 @@ Client::handleStopRetry(const Event&, void*)
|
|||
m_args.m_restartable = false;
|
||||
}
|
||||
|
||||
void
|
||||
Client::writeToDropDirThread(void*)
|
||||
void Client::write_to_drop_dir_thread()
|
||||
{
|
||||
LOG((CLOG_DEBUG "starting write to drop dir thread"));
|
||||
|
||||
|
@ -812,18 +808,13 @@ Client::sendFileToServer(const char* filename)
|
|||
StreamChunker::interruptFile();
|
||||
}
|
||||
|
||||
m_sendFileThread = new Thread(
|
||||
new TMethodJob<Client>(
|
||||
this, &Client::sendFileThread,
|
||||
static_cast<void*>(const_cast<char*>(filename))));
|
||||
m_sendFileThread = new Thread([this, filename]() { send_file_thread(filename); });
|
||||
}
|
||||
|
||||
void
|
||||
Client::sendFileThread(void* filename)
|
||||
void Client::send_file_thread(const char* filename)
|
||||
{
|
||||
try {
|
||||
char* name = static_cast<char*>(filename);
|
||||
StreamChunker::sendFile(name, m_events, this);
|
||||
StreamChunker::sendFile(filename, m_events, this);
|
||||
}
|
||||
catch (std::runtime_error& error) {
|
||||
LOG((CLOG_ERR "failed sending file chunks: %s", error.what()));
|
||||
|
|
|
@ -167,8 +167,8 @@ private:
|
|||
void sendEvent(Event::Type, void*);
|
||||
void sendConnectionFailedEvent(const char* msg);
|
||||
void sendFileChunk(const void* data);
|
||||
void sendFileThread(void*);
|
||||
void writeToDropDirThread(void*);
|
||||
void send_file_thread(const char* filename);
|
||||
void write_to_drop_dir_thread();
|
||||
void setupConnecting();
|
||||
void setupConnection();
|
||||
void setupScreen();
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "base/Event.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
enum EIpcLogOutputter {
|
||||
kBufferMaxSize = 1000,
|
||||
|
@ -54,8 +53,7 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType
|
|||
m_clientType(clientType)
|
||||
{
|
||||
if (useThread) {
|
||||
m_bufferThread = new Thread(new TMethodJob<IpcLogOutputter>(
|
||||
this, &IpcLogOutputter::bufferThread));
|
||||
m_bufferThread = new Thread([this](){ buffer_thread(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,8 +140,7 @@ IpcLogOutputter::isRunning()
|
|||
return m_running;
|
||||
}
|
||||
|
||||
void
|
||||
IpcLogOutputter::bufferThread(void*)
|
||||
void IpcLogOutputter::buffer_thread()
|
||||
{
|
||||
m_bufferThreadId = m_bufferThread->getID();
|
||||
m_running = true;
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
private:
|
||||
void init();
|
||||
void bufferThread(void*);
|
||||
void buffer_thread();
|
||||
std::string getChunk(size_t count);
|
||||
void appendBuffer(const std::string& text);
|
||||
bool isRunning();
|
||||
|
|
|
@ -28,12 +28,10 @@
|
|||
// Thread
|
||||
//
|
||||
|
||||
Thread::Thread(IJob* job)
|
||||
Thread::Thread(const std::function<void()>& fun)
|
||||
{
|
||||
m_thread = ARCH->newThread([job](){ threadFunc(job); });
|
||||
m_thread = ARCH->newThread([=](){ threadFunc(fun); });
|
||||
if (m_thread == NULL) {
|
||||
// couldn't create thread
|
||||
delete job;
|
||||
throw XMTThreadUnavailable();
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +124,7 @@ Thread::operator!=(const Thread& thread) const
|
|||
return !ARCH->isSameThread(m_thread, thread.m_thread);
|
||||
}
|
||||
|
||||
void Thread::threadFunc(IJob* job)
|
||||
void Thread::threadFunc(const std::function<void()>& func)
|
||||
{
|
||||
// get this thread's id for logging
|
||||
IArchMultithread::ThreadID id;
|
||||
|
@ -139,13 +137,12 @@ void Thread::threadFunc(IJob* job)
|
|||
try {
|
||||
// go
|
||||
LOG((CLOG_DEBUG1 "thread 0x%08x entry", id));
|
||||
job->run();
|
||||
func();
|
||||
LOG((CLOG_DEBUG1 "thread 0x%08x exit", id));
|
||||
}
|
||||
catch (XThreadCancel&) {
|
||||
// client called cancel()
|
||||
LOG((CLOG_DEBUG1 "caught cancel on thread 0x%08x", id));
|
||||
delete job;
|
||||
throw;
|
||||
}
|
||||
catch (XThreadExit&) {
|
||||
|
@ -153,15 +150,10 @@ void Thread::threadFunc(IJob* job)
|
|||
}
|
||||
catch (XBase& e) {
|
||||
LOG((CLOG_ERR "exception on thread 0x%08x: %s", id, e.what()));
|
||||
delete job;
|
||||
throw;
|
||||
}
|
||||
catch (...) {
|
||||
LOG((CLOG_ERR "exception on thread 0x%08x: <unknown>", id));
|
||||
delete job;
|
||||
throw;
|
||||
}
|
||||
|
||||
// done with job
|
||||
delete job;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "arch/IArchMultithread.h"
|
||||
|
||||
class IJob;
|
||||
#include <functional>
|
||||
|
||||
//! Thread handle
|
||||
/*!
|
||||
|
@ -44,10 +43,9 @@ class Thread {
|
|||
public:
|
||||
//! Run \c adoptedJob in a new thread
|
||||
/*!
|
||||
Create and start a new thread executing the \c adoptedJob. The
|
||||
new thread takes ownership of \c adoptedJob and will delete it.
|
||||
Create and start a new thread executing the \c fun.
|
||||
*/
|
||||
Thread(IJob* adoptedJob);
|
||||
Thread(const std::function<void()>& fun);
|
||||
|
||||
//! Duplicate a thread handle
|
||||
/*!
|
||||
|
@ -192,7 +190,7 @@ public:
|
|||
private:
|
||||
Thread(ArchThread);
|
||||
|
||||
static void threadFunc(IJob*);
|
||||
static void threadFunc(const std::function<void()>& func);
|
||||
|
||||
private:
|
||||
ArchThread m_thread;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "arch/Arch.h"
|
||||
#include "arch/XArch.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "common/stdvector.h"
|
||||
|
||||
//
|
||||
|
@ -58,8 +57,7 @@ SocketMultiplexer::SocketMultiplexer() :
|
|||
m_jobListLockLocker(NULL)
|
||||
{
|
||||
// start thread
|
||||
m_thread = new Thread(new TMethodJob<SocketMultiplexer>(
|
||||
this, &SocketMultiplexer::serviceThread));
|
||||
m_thread = new Thread([this](){ service_thread(); });
|
||||
}
|
||||
|
||||
SocketMultiplexer::~SocketMultiplexer()
|
||||
|
@ -95,7 +93,7 @@ void SocketMultiplexer::addSocket(ISocket* socket, std::unique_ptr<ISocketMultip
|
|||
if (i == m_socketJobMap.end()) {
|
||||
// we *must* put the job at the end so the order of jobs in
|
||||
// the list continue to match the order of jobs in pfds in
|
||||
// serviceThread().
|
||||
// service_thread().
|
||||
JobCursor j = m_socketJobs.insert(m_socketJobs.end(), std::move(job));
|
||||
m_update = true;
|
||||
m_socketJobMap.insert(std::make_pair(socket, j));
|
||||
|
@ -125,7 +123,7 @@ SocketMultiplexer::removeSocket(ISocket* socket)
|
|||
|
||||
// remove job. rather than removing it from the map we put NULL
|
||||
// in the list instead so the order of jobs in the list continues
|
||||
// to match the order of jobs in pfds in serviceThread().
|
||||
// to match the order of jobs in pfds in service_thread().
|
||||
SocketJobMap::iterator i = m_socketJobMap.find(socket);
|
||||
if (i != m_socketJobMap.end()) {
|
||||
if (*(i->second)) {
|
||||
|
@ -138,8 +136,7 @@ SocketMultiplexer::removeSocket(ISocket* socket)
|
|||
unlockJobList();
|
||||
}
|
||||
|
||||
void
|
||||
SocketMultiplexer::serviceThread(void*)
|
||||
void SocketMultiplexer::service_thread()
|
||||
{
|
||||
std::vector<IArchNetwork::PollEntry> pfds;
|
||||
IArchNetwork::PollEntry pfd;
|
||||
|
|
|
@ -67,7 +67,7 @@ private:
|
|||
// and m_update while m_pollable and m_polling are true. all other
|
||||
// threads must only modify these when m_pollable and m_polling are
|
||||
// false. only the service thread sets m_polling.
|
||||
void serviceThread(void*);
|
||||
void service_thread();
|
||||
|
||||
// create, iterate, and destroy a cursor. a cursor is used to
|
||||
// safely iterate through the job list while other threads modify
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/IEventQueue.h"
|
||||
|
||||
#include <malloc.h>
|
||||
|
@ -599,13 +598,11 @@ MSWindowsDesks::deskLeave(Desk* desk, HKL keyLayout)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsDesks::deskThread(void* vdesk)
|
||||
void MSWindowsDesks::desk_thread(Desk* desk)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
// use given desktop for this thread
|
||||
Desk* desk = static_cast<Desk*>(vdesk);
|
||||
desk->m_threadID = GetCurrentThreadId();
|
||||
desk->m_window = NULL;
|
||||
desk->m_foregroundWindow = NULL;
|
||||
|
@ -749,8 +746,7 @@ MSWindowsDesks::Desk* MSWindowsDesks::addDesk(const std::string& name, HDESK hde
|
|||
desk->m_name = name;
|
||||
desk->m_desk = hdesk;
|
||||
desk->m_targetID = GetCurrentThreadId();
|
||||
desk->m_thread = new Thread(new TMethodJob<MSWindowsDesks>(
|
||||
this, &MSWindowsDesks::deskThread, desk));
|
||||
desk->m_thread = new Thread([this, desk]() { desk_thread(desk); });
|
||||
waitForDesk();
|
||||
m_desks.insert(std::make_pair(name, desk));
|
||||
return desk;
|
||||
|
|
|
@ -220,7 +220,7 @@ private:
|
|||
void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
||||
void deskEnter(Desk* desk);
|
||||
void deskLeave(Desk* desk, HKL keyLayout);
|
||||
void deskThread(void* vdesk);
|
||||
void desk_thread(Desk* desk);
|
||||
|
||||
// desk switch checking and handling
|
||||
Desk* addDesk(const std::string& name, HDESK hdesk);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "platform/MSWindowsDesks.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "arch/win32/ArchMiscWindows.h"
|
||||
#include "base/FunctionJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/String.h"
|
||||
#include "base/IEventQueue.h"
|
||||
|
@ -804,15 +803,14 @@ MSWindowsKeyState::fakeCtrlAltDel()
|
|||
CloseHandle(hEvtSendSas);
|
||||
}
|
||||
else {
|
||||
Thread cad(new FunctionJob(&MSWindowsKeyState::ctrlAltDelThread));
|
||||
Thread cad([this](){ ctrl_alt_del_thread(); });
|
||||
cad.wait();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsKeyState::ctrlAltDelThread(void*)
|
||||
void MSWindowsKeyState::ctrl_alt_del_thread()
|
||||
{
|
||||
// get the Winlogon desktop at whatever privilege we can
|
||||
HDESK desk = OpenDesktop("Winlogon", 0, FALSE, MAXIMUM_ALLOWED);
|
||||
|
|
|
@ -169,7 +169,7 @@ private:
|
|||
typedef std::vector<HKL> GroupList;
|
||||
|
||||
// send ctrl+alt+del hotkey event on NT family
|
||||
static void ctrlAltDelThread(void*);
|
||||
static void ctrl_alt_del_thread();
|
||||
|
||||
bool getGroups(GroupList&) const;
|
||||
void setWindowGroup(SInt32 group);
|
||||
|
|
|
@ -36,11 +36,9 @@
|
|||
#include "mt/Thread.h"
|
||||
#include "arch/win32/ArchMiscWindows.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/FunctionJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <Shlobj.h>
|
||||
|
@ -354,17 +352,13 @@ MSWindowsScreen::leave()
|
|||
forceShowCursor();
|
||||
|
||||
if (isDraggingStarted() && !m_isPrimary) {
|
||||
m_sendDragThread = new Thread(
|
||||
new TMethodJob<MSWindowsScreen>(
|
||||
this,
|
||||
&MSWindowsScreen::sendDragThread));
|
||||
m_sendDragThread = new Thread([this](){ send_drag_thread(); });
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsScreen::sendDragThread(void*)
|
||||
void MSWindowsScreen::send_drag_thread()
|
||||
{
|
||||
std::string& draggingFilename = getDraggingFilename();
|
||||
size_t size = draggingFilename.size();
|
||||
|
|
|
@ -222,7 +222,7 @@ private: // HACK
|
|||
KeyModifierMask state, WPARAM wParam) const;
|
||||
|
||||
// send drag info and data back to server
|
||||
void sendDragThread(void*);
|
||||
void send_drag_thread();
|
||||
|
||||
private:
|
||||
struct HotKeyItem {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "arch/Arch.h"
|
||||
#include "arch/win32/ArchMiscWindows.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <tchar.h>
|
||||
|
@ -223,8 +222,7 @@ MSWindowsScreenSaver::watchDesktop()
|
|||
// watch desktop in another thread
|
||||
LOG((CLOG_DEBUG "watching screen saver desktop"));
|
||||
m_active = true;
|
||||
m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this,
|
||||
&MSWindowsScreenSaver::watchDesktopThread));
|
||||
m_watch = new Thread([this](){ watch_desktop_thread(); });
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -238,8 +236,7 @@ MSWindowsScreenSaver::watchProcess(HANDLE process)
|
|||
LOG((CLOG_DEBUG "watching screen saver process"));
|
||||
m_process = process;
|
||||
m_active = true;
|
||||
m_watch = new Thread(new TMethodJob<MSWindowsScreenSaver>(this,
|
||||
&MSWindowsScreenSaver::watchProcessThread));
|
||||
m_watch = new Thread([this](){ watch_process_thread(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,8 +257,7 @@ MSWindowsScreenSaver::unwatchProcess()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsScreenSaver::watchDesktopThread(void*)
|
||||
void MSWindowsScreenSaver::watch_desktop_thread()
|
||||
{
|
||||
DWORD reserved = 0;
|
||||
TCHAR* name = NULL;
|
||||
|
@ -283,8 +279,7 @@ MSWindowsScreenSaver::watchDesktopThread(void*)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsScreenSaver::watchProcessThread(void*)
|
||||
void MSWindowsScreenSaver::watch_process_thread()
|
||||
{
|
||||
for (;;) {
|
||||
Thread::testCancel();
|
||||
|
|
|
@ -64,8 +64,8 @@ private:
|
|||
void watchDesktop();
|
||||
void watchProcess(HANDLE process);
|
||||
void unwatchProcess();
|
||||
void watchDesktopThread(void*);
|
||||
void watchProcessThread(void*);
|
||||
void watch_desktop_thread();
|
||||
void watch_process_thread();
|
||||
|
||||
void setSecure(bool secure, bool saveSecureAsInt);
|
||||
bool isSecure(bool* wasSecureAnInt) const;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "arch/win32/XArchWindows.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/log_outputters.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/Log.h"
|
||||
#include "common/Version.h"
|
||||
|
||||
|
@ -84,11 +83,8 @@ MSWindowsWatchdog::MSWindowsWatchdog(
|
|||
void
|
||||
MSWindowsWatchdog::startAsync()
|
||||
{
|
||||
m_thread = new Thread(new TMethodJob<MSWindowsWatchdog>(
|
||||
this, &MSWindowsWatchdog::mainLoop, nullptr));
|
||||
|
||||
m_outputThread = new Thread(new TMethodJob<MSWindowsWatchdog>(
|
||||
this, &MSWindowsWatchdog::outputLoop, nullptr));
|
||||
m_thread = new Thread([this](){ main_loop(); });
|
||||
m_outputThread = new Thread([this](){ output_loop(); });
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -157,8 +153,7 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsWatchdog::mainLoop(void*)
|
||||
void MSWindowsWatchdog::main_loop()
|
||||
{
|
||||
shutdownExistingProcesses();
|
||||
|
||||
|
@ -421,8 +416,7 @@ MSWindowsWatchdog::getCommand() const
|
|||
return cmd;
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsWatchdog::outputLoop(void*)
|
||||
void MSWindowsWatchdog::output_loop()
|
||||
{
|
||||
// +1 char for \0
|
||||
CHAR buffer[kOutputBufferSize + 1];
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
void setFileLogOutputter(FileLogOutputter* outputter);
|
||||
|
||||
private:
|
||||
void mainLoop(void*);
|
||||
void outputLoop(void*);
|
||||
void main_loop();
|
||||
void output_loop();
|
||||
void shutdownProcess(HANDLE handle, DWORD pid, int timeout);
|
||||
void shutdownExistingProcesses();
|
||||
HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security);
|
||||
|
|
|
@ -174,7 +174,7 @@ private:
|
|||
EventRef theEvent, void* inUserData);
|
||||
|
||||
// sleep / wakeup support
|
||||
void watchSystemPowerThread(void*);
|
||||
void watchSystemPowerThread();
|
||||
static void testCanceled(CFRunLoopTimerRef timer, void*info);
|
||||
static void powerChangeCallback(void* refcon, io_service_t service,
|
||||
natural_t messageType, void* messageArgument);
|
||||
|
@ -201,7 +201,7 @@ private:
|
|||
// convert CFString to char*
|
||||
static char* CFStringRefToUTF8String(CFStringRef aString);
|
||||
|
||||
void getDropTargetThread(void*);
|
||||
void get_drop_target_thread();
|
||||
|
||||
private:
|
||||
struct HotKeyItem {
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <mach-o/dyld.h>
|
||||
|
@ -157,8 +156,7 @@ OSXScreen::OSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCurso
|
|||
m_carbonLoopReady = new CondVar<bool>(m_carbonLoopMutex, false);
|
||||
#endif
|
||||
LOG((CLOG_DEBUG "starting watchSystemPowerThread"));
|
||||
m_pmWatchThread = new Thread(new TMethodJob<OSXScreen>
|
||||
(this, &OSXScreen::watchSystemPowerThread));
|
||||
m_pmWatchThread = new Thread([this](){ watchSystemPowerThread(); });
|
||||
}
|
||||
catch (...) {
|
||||
m_events->removeHandler(m_events->forOSXScreen().confirmSleep(),
|
||||
|
@ -578,16 +576,14 @@ OSXScreen::fakeMouseButton(ButtonID id, bool press)
|
|||
|
||||
if (!press && (id == kButtonLeft)) {
|
||||
if (m_fakeDraggingStarted) {
|
||||
m_getDropTargetThread = new Thread(new TMethodJob<OSXScreen>(
|
||||
this, &OSXScreen::getDropTargetThread));
|
||||
m_getDropTargetThread = new Thread([this](){ get_drop_target_thread(); });
|
||||
}
|
||||
|
||||
m_draggingStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OSXScreen::getDropTargetThread(void*)
|
||||
void OSXScreen::get_drop_target_thread()
|
||||
{
|
||||
#if defined(MAC_OS_X_VERSION_10_7)
|
||||
char* cstr = NULL;
|
||||
|
@ -1186,8 +1182,7 @@ OSXScreen::onMouseButton(bool pressed, UInt16 macButton)
|
|||
}
|
||||
else {
|
||||
if (m_fakeDraggingStarted) {
|
||||
m_getDropTargetThread = new Thread(new TMethodJob<OSXScreen>(
|
||||
this, &OSXScreen::getDropTargetThread));
|
||||
m_getDropTargetThread = new Thread([this](){ get_drop_target_thread(); });
|
||||
}
|
||||
|
||||
m_draggingStarted = false;
|
||||
|
@ -1621,8 +1616,7 @@ OSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler,
|
|||
// main of thread monitoring system power (sleep/wakeup) using a CFRunLoop
|
||||
//
|
||||
|
||||
void
|
||||
OSXScreen::watchSystemPowerThread(void*)
|
||||
void OSXScreen::watchSystemPowerThread()
|
||||
{
|
||||
io_object_t notifier;
|
||||
IONotificationPortRef notificationPortRef;
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "net/XSocket.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
|
@ -1824,10 +1823,8 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
|
|||
&& m_active != newScreen
|
||||
&& m_waitDragInfoThread) {
|
||||
if (m_sendDragInfoThread == NULL) {
|
||||
m_sendDragInfoThread = new Thread(
|
||||
new TMethodJob<Server>(
|
||||
this,
|
||||
&Server::sendDragInfoThread, newScreen));
|
||||
m_sendDragInfoThread = new Thread([this, newScreen]()
|
||||
{ send_drag_info_thread(newScreen); });
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1843,11 +1840,8 @@ Server::onMouseMovePrimary(SInt32 x, SInt32 y)
|
|||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Server::sendDragInfoThread(void* arg)
|
||||
void Server::send_drag_info_thread(BaseClientProxy* newScreen)
|
||||
{
|
||||
BaseClientProxy* newScreen = static_cast<BaseClientProxy*>(arg);
|
||||
|
||||
m_dragFileList.clear();
|
||||
std::string& dragFileList = m_screen->getDraggingFilename();
|
||||
if (!dragFileList.empty()) {
|
||||
|
@ -2087,14 +2081,11 @@ void
|
|||
Server::onFileRecieveCompleted()
|
||||
{
|
||||
if (isReceivedFileSizeValid()) {
|
||||
m_writeToDropDirThread = new Thread(
|
||||
new TMethodJob<Server>(
|
||||
this, &Server::writeToDropDirThread));
|
||||
m_writeToDropDirThread = new Thread([this]() { write_to_drop_dir_thread(); });
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Server::writeToDropDirThread(void*)
|
||||
void Server::write_to_drop_dir_thread()
|
||||
{
|
||||
LOG((CLOG_DEBUG "starting write to drop dir thread"));
|
||||
|
||||
|
@ -2394,17 +2385,12 @@ Server::sendFileToClient(const char* filename)
|
|||
StreamChunker::interruptFile();
|
||||
}
|
||||
|
||||
m_sendFileThread = new Thread(
|
||||
new TMethodJob<Server>(
|
||||
this, &Server::sendFileThread,
|
||||
static_cast<void*>(const_cast<char*>(filename))));
|
||||
m_sendFileThread = new Thread([this, filename]() { send_file_thread(filename); });
|
||||
}
|
||||
|
||||
void
|
||||
Server::sendFileThread(void* data)
|
||||
void Server::send_file_thread(const char* filename)
|
||||
{
|
||||
try {
|
||||
char* filename = static_cast<char*>(data);
|
||||
LOG((CLOG_DEBUG "sending file to client, filename=%s", filename));
|
||||
StreamChunker::sendFile(filename, m_events, this);
|
||||
}
|
||||
|
|
|
@ -358,13 +358,13 @@ private:
|
|||
void forceLeaveClient(BaseClientProxy* client);
|
||||
|
||||
// thread function for sending file
|
||||
void sendFileThread(void*);
|
||||
void send_file_thread(const char* filename);
|
||||
|
||||
// thread function for writing file to drop directory
|
||||
void writeToDropDirThread(void*);
|
||||
void write_to_drop_dir_thread();
|
||||
|
||||
// thread function for sending drag information
|
||||
void sendDragInfoThread(void*);
|
||||
void send_drag_info_thread(BaseClientProxy* newScreen);
|
||||
|
||||
// send drag info to new client screen
|
||||
void sendDragInfo(BaseClientProxy* newScreen);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "net/SocketMultiplexer.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/String.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/EventQueue.h"
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "net/TCPSocketFactory.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
#include "base/Log.h"
|
||||
#include <stdexcept>
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "platform/MSWindowsDesks.h"
|
||||
#include "platform/MSWindowsScreen.h"
|
||||
#include "platform/MSWindowsScreenSaver.h"
|
||||
#include "base/TMethodJob.h"
|
||||
|
||||
#include "test/global/gtest.h"
|
||||
#include "test/global/gmock.h"
|
||||
|
|
Loading…
Reference in New Issue