~ci-train-bot/location-service/location-service-ubuntu-vivid-landing-019

« back to all changes in this revision

Viewing changes to src/location_service/com/ubuntu/location/providers/dummy/delayed_provider.cpp

  • Committer: CI Train Bot
  • Author(s): Scott Sweeny
  • Date: 2016-01-06 16:15:26 UTC
  • mfrom: (197.4.11 async-providers.15.04)
  • Revision ID: ci-train-bot@canonical.com-20160106161526-ayi7kslo1eon3d53
Allow providers to register themselves asynchronously Fixes: #1415029
Approved by: Thomas Voß

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Scott Sweeny <scott.sweeny@canonical.com>
 
17
 */
 
18
 
 
19
#include <com/ubuntu/location/logging.h>
 
20
 
 
21
#include <chrono>
 
22
#include <thread>
 
23
 
 
24
#include "delayed_provider.h"
 
25
 
 
26
namespace location = com::ubuntu::location;
 
27
namespace dummy = com::ubuntu::location::providers::dummy;
 
28
 
 
29
std::string dummy::DelayedProvider::class_name()
 
30
{
 
31
    return "dummy::DelayedProvider";
 
32
}
 
33
 
 
34
location::Provider::Ptr dummy::DelayedProvider::create_instance(const ProviderFactory::Configuration& config)
 
35
{
 
36
    int delay = config.get(dummy::DelayConfiguration::Keys::delay, 0);
 
37
    VLOG(1) << __PRETTY_FUNCTION__ << ": delay for " << delay << "ms";
 
38
 
 
39
    std::this_thread::sleep_for(std::chrono::milliseconds{delay});
 
40
 
 
41
    return dummy::Provider::create_instance(config);
 
42
}