summaryrefslogtreecommitdiff
path: root/usrp2/host/lib/usrp2_thread.cc
blob: 9e4e6dbefd5998805a38d53c90967786072c06ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* -*- c++ -*- */
/*
 * Copyright 2008 Free Software Foundation, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program 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/>.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "usrp2_thread.h"
#include "usrp2_impl.h"
#include <gruel/realtime.h>
#include <iostream>

#define USRP2_THREAD_DEBUG 1

namespace usrp2 {

  usrp2_thread::usrp2_thread(usrp2::impl *u2) :
    omni_thread(NULL, PRIORITY_HIGH),
    d_u2(u2)
  {
  }
  
  usrp2_thread::~usrp2_thread()
  {
    // we don't own this, just forget it
    d_u2 = 0;
  }
  
  void
  usrp2_thread::start()
  {
    start_undetached();
  }
  
  void *
  usrp2_thread::run_undetached(void *arg)
  {
    if (gruel::enable_realtime_scheduling() != gruel::RT_OK)
      std::cerr << "usrp2: failed to enable realtime scheduling" << std::endl;    

    // This is the first code to run in the new thread context.
    d_u2->bg_loop();
    
    return 0;
  }

} // namespace usrp2