mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-03-04 03:07:29 +01:00
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
69 lines
964 B
C++
69 lines
964 B
C++
//
|
|
// Activity.cpp
|
|
//
|
|
// This sample demonstrates the Activity class.
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/Activity.h"
|
|
#include "Poco/Thread.h"
|
|
#include <iostream>
|
|
|
|
|
|
using Poco::Activity;
|
|
using Poco::Thread;
|
|
|
|
|
|
class ActivityExample
|
|
{
|
|
public:
|
|
ActivityExample():
|
|
_activity(this, &ActivityExample::runActivity)
|
|
{
|
|
}
|
|
|
|
void start()
|
|
{
|
|
_activity.start();
|
|
}
|
|
|
|
void stop()
|
|
{
|
|
_activity.stop();
|
|
_activity.wait();
|
|
}
|
|
|
|
protected:
|
|
void runActivity()
|
|
{
|
|
while (!_activity.isStopped())
|
|
{
|
|
std::cout << "Activity running." << std::endl;
|
|
Thread::sleep(250);
|
|
}
|
|
std::cout << "Activity stopped." << std::endl;
|
|
}
|
|
|
|
private:
|
|
Activity<ActivityExample> _activity;
|
|
};
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
ActivityExample example;
|
|
example.start();
|
|
Thread::sleep(2000);
|
|
example.stop();
|
|
|
|
example.start();
|
|
example.stop();
|
|
|
|
return 0;
|
|
}
|