~ubuntu-branches/ubuntu/intrepid/pyxine/intrepid-proposed

« back to all changes in this revision

Viewing changes to pxlib/Thread.cc

  • Committer: Bazaar Package Importer
  • Author(s): Joe Wreschnig
  • Date: 2003-11-11 12:13:24 UTC
  • Revision ID: james.westby@ubuntu.com-20031111121324-y3z5cd02mf87o0gn
Tags: upstream-0.1alpha2
ImportĀ upstreamĀ versionĀ 0.1alpha2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-c++-*-
 
2
 *
 
3
 * $Id: Thread.cc,v 1.1.1.1 2003/02/08 00:42:21 dairiki Exp $
 
4
 *
 
5
 * Copyright (C) 2003 Geoffrey T. Dairiki
 
6
 *
 
7
 * This file is part of Pyxine, Python bindings for xine.
 
8
 *
 
9
 * Pyxine is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License
 
11
 * as published by the Free Software Foundation; either version 2
 
12
 * of the License, or (at your option) any later version.
 
13
 *
 
14
 * Pyxine is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
22
 */
 
23
#pragma implementation
 
24
#include "Thread.h"
 
25
 
 
26
BEGIN_PXLIB_NAMESPACE
 
27
void *
 
28
ThreadRunner::c_thread_runner (void *data)
 
29
{
 
30
  static_cast<pyxine::Thread *>(data)->run();
 
31
  return 0;
 
32
}
 
33
 
 
34
 
 
35
ThreadRunner::ThreadRunner (Thread * thread)
 
36
{
 
37
  pthread_create(&t, NULL, c_thread_runner, thread);
 
38
}
 
39
 
 
40
 
 
41
ThreadRunner::~ThreadRunner ()
 
42
{
 
43
  cerr << "Stopping Thread" << endl;
 
44
  // FIXME: check for errors
 
45
  pthread_cancel(t);
 
46
  pthread_join(t, NULL);
 
47
  cerr << "Thread stopped" << endl;
 
48
}
 
49
 
 
50
END_PXLIB_NAMESPACE