Keyple Service C++ Library - 3.3.5
Component of the Keyple C++ middleware
Job.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/core/service/cpp/Job.hpp"
15
16#include <iostream>
17#include <string>
18
19#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
20
21namespace keyple {
22namespace core {
23namespace service {
24namespace cpp {
25
26using keyple::core::util::cpp::exception::IllegalArgumentException;
27
28Job::Job(const std::string& name)
29: Thread(name)
30, mCancelled(false)
31{
32}
33
34bool
35Job::cancel(const bool mayInterruptIfRunning)
36{
37 if (mayInterruptIfRunning) {
38 throw IllegalArgumentException(
39 "Unsupported value for mayInterruptIfRunning (true)");
40 }
41
42 mCancelled = true;
43
44 if (!isAlive()) {
45 return false;
46 }
47
48 return true;
49}
50
51bool
52Job::isDone()
53{
54 return mDone;
55}
56
57bool
58Job::isCancelled() const
59{
60 return mCancelled;
61}
62
63} /* namespace cpp */
64} /* namespace service */
65} /* namespace core */
66} /* namespace keyple */