File: bsecore.cc

package info (click to toggle)
beast 0.7.4-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 33,500 kB
  • sloc: ansic: 197,348; cpp: 59,114; sh: 11,030; perl: 2,523; makefile: 2,474; xml: 1,026; lisp: 549; awk: 270; sed: 8
file content (102 lines) | stat: -rw-r--r-- 3,218 bytes parent folder | download
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* BSE - Better Sound Engine
 * Copyright (C) 2004 Tim Janik
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * A copy of the GNU Lesser General Public License should ship along
 * with this library; if not, see http://www.gnu.org/copyleft/.
 */
#include "bsetype.h"        /* import all required types first */
#include "bsepart.h"
#include "bsemain.h"
#include "bseengine.h"
#include "bsesequencer.h"
#include "bsecxxplugin.hh" /* includes bsecore.genidl.hh for us */

namespace Bse {

namespace Procedure {
ThreadTotalsHandle
collect_thread_totals::exec ()
{
  struct Sub {
    static ThreadState convert (BirnetThreadState ts)
    {
      switch (ts)
        {
        default:
        case BIRNET_THREAD_UNKNOWN:     return THREAD_STATE_UNKNOWN;
        case BIRNET_THREAD_RUNNING:     return THREAD_STATE_RUNNING;
        case BIRNET_THREAD_SLEEPING:    return THREAD_STATE_SLEEPING;
        case BIRNET_THREAD_DISKWAIT:    return THREAD_STATE_DISKWAIT;
        case BIRNET_THREAD_TRACED:      return THREAD_STATE_TRACED;
        case BIRNET_THREAD_PAGING:      return THREAD_STATE_PAGING;
        case BIRNET_THREAD_ZOMBIE:      return THREAD_STATE_ZOMBIE;
        case BIRNET_THREAD_DEAD:        return THREAD_STATE_DEAD;
        }
    }
    static void assign (ThreadInfoHandle &th,
                        BirnetThreadInfo    *ti)
    {
      th->name = ti->name;
      th->thread_id = ti->thread_id;
      th->state = convert (ti->state);
      th->priority = ti->priority;
      th->processor = ti->processor;
      th->utime = ti->utime;
      th->stime = ti->stime;
      th->cutime = ti->cutime;
      th->cstime = ti->cstime;
    }
  };
  ThreadTotalsHandle tth (Sfi::INIT_DEFAULT);
  BirnetThreadInfo *ti;
  ti = sfi_thread_info_collect (bse_main_thread);
  tth->main = ThreadInfoHandle (Sfi::INIT_DEFAULT);
  Sub::assign (tth->main, ti);
  sfi_thread_info_free (ti);
  if (bse_sequencer_thread)
    {
      ti = sfi_thread_info_collect (bse_sequencer_thread);
      tth->sequencer = ThreadInfoHandle (Sfi::INIT_DEFAULT);
      Sub::assign (tth->sequencer, ti);
      sfi_thread_info_free (ti);
    }
  guint n;
  BirnetThread **t;
  t = bse_engine_get_threads (&n);
  for (guint i = 0; i < n; i++)
    {
      ti = sfi_thread_info_collect (t[i]);
      tth->synthesis.resize (i + 1);
      tth->synthesis[i] = ThreadInfoHandle (Sfi::INIT_DEFAULT);
      Sub::assign (tth->synthesis[i], ti);
      sfi_thread_info_free (ti);
    }
  g_free (t);
  return tth;
}

} // Procedure

/* export definitions follow */
BSE_CXX_DEFINE_EXPORTS();
BSE_CXX_REGISTER_ALL_TYPES_FROM_BSECORE_IDL();

} // Bse

/* compile and initialize generated C stubs */
#include "bsegencore.cc"
void
_bse_init_c_wrappers (void)
{
  sfidl_types_init ();
}