use pthread_t * handlers rather than pthread_t

pthread-win32 doesn't accept assigning zero to pthread_t type,
so we need to use pointers instead. this is more semantic anyway.
master
Andrzej Rybczak 17 years ago
parent c634059834
commit 344fc21d76
  1. 14
      src/info.cpp
  2. 2
      src/info.h
  3. 11
      src/lyrics.cpp
  4. 5
      src/lyrics.h
  5. 6
      src/ncmpcpp.h

@ -27,9 +27,6 @@
# else
# include <sys/stat.h>
# endif // WIN32
# ifdef HAVE_PTHREAD_H
# include <pthread.h>
# endif
# include "curl/curl.h"
# include "helpers.h"
#endif
@ -53,7 +50,7 @@ const std::string Info::Folder = home_folder + "/.ncmpcpp/artists";
bool Info::ArtistReady = 0;
#ifdef HAVE_PTHREAD_H
pthread_t Info::Downloader = 0;
pthread_t *Info::Downloader = 0;
#endif // HAVE_PTHREAD_H
#endif // HAVE_CURL_CURL_H
@ -83,8 +80,9 @@ void Info::Update()
if (!ArtistReady)
return;
pthread_join(Downloader, NULL);
pthread_join(*Downloader, NULL);
w->Flush();
delete Downloader;
Downloader = 0;
ArtistReady = 0;
}
@ -158,8 +156,12 @@ void Info::GetArtist()
static_cast<Window &>(*w) << "Fetching artist's info...";
# ifdef HAVE_PTHREAD_H
if (!Downloader)
pthread_create(&Downloader, NULL, PrepareArtist, artist);
{
Downloader = new pthread_t;
pthread_create(Downloader, NULL, PrepareArtist, artist);
}
# else
w->Window::Refresh();
PrepareArtist(&artist);
w->Flush();
# endif // HAVE_PTHREAD_H

@ -61,7 +61,7 @@ class Info : public Screen<Scrollpad>
static bool ArtistReady;
# ifdef HAVE_PTHREAD_H
static pthread_t Downloader;
static pthread_t *Downloader;
# endif // HAVE_PTHREAD_H
# endif // HAVE_CURL_CURL_H

@ -54,7 +54,7 @@ bool Lyrics::Ready = 0;
std::string Lyrics::Filename;
#ifdef HAVE_PTHREAD_H
pthread_t Lyrics::Downloader = 0;
pthread_t *Lyrics::Downloader = 0;
pthread_mutex_t Global::CurlLock = PTHREAD_MUTEX_INITIALIZER;
#endif // HAVE_PTHREAD_H
@ -134,8 +134,12 @@ void Lyrics::SwitchTo()
# endif // HAVE_CURL_CURL_H
# ifdef HAVE_PTHREAD_H
if (!Downloader)
pthread_create(&Downloader, NULL, Get, &itsSong);
{
Downloader = new pthread_t;
pthread_create(Downloader, NULL, Get, &itsSong);
}
# else
w->Window::Refresh();
Get(&itsSong);
w->Flush();
# endif // HAVE_PTHREAD_H
@ -297,8 +301,9 @@ void Lyrics::Take()
{
if (!Ready)
return;
pthread_join(Downloader, NULL);
pthread_join(*Downloader, NULL);
w->Flush();
delete Downloader;
Downloader = 0;
Ready = 0;
}

@ -26,9 +26,6 @@
#include "screen.h"
#ifdef HAVE_CURL_CURL_H
# ifdef HAVE_PTHREAD_H
# include <pthread.h>
# endif
# include "curl/curl.h"
#endif
@ -88,7 +85,7 @@ class Lyrics : public Screen<Scrollpad>
static bool Ready;
# ifdef HAVE_PTHREAD_H
static pthread_t Downloader;
static pthread_t *Downloader;
# endif // HAVE_PTHREAD_H
static const char *PluginsList[];

@ -27,11 +27,13 @@
#include "menu.h"
#include "scrollpad.h"
#ifndef HAVE_PTHREAD_H
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#else
# define pthread_mutex_lock(x);
# define pthread_mutex_unlock(x);
# define pthread_exit(x) return 0;
#endif
#endif // HAVE_PTHREAD_H
using namespace NCurses;

Loading…
Cancel
Save