Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3266 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Dec 24, 2004, 2:58:32 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: race-condition-prevention.

Location:
orxonox/branches/updater/src/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui_update.cc

    r3263 r3266  
    3030#include "orxonox_gui.h"
    3131#include <stdio.h>
     32#ifdef HAVE_CURL
    3233#include <curl/curl.h>
    3334#include <curl/types.h>
    34 #include <curl/easy.h> /* new for v7 */
     35#include <curl/easy.h>
     36#endif /* HAVE_CURL */
    3537using namespace std;
    3638
     
    154156  strcpy (info->fileOnDisk, "test");
    155157  info->fileOnNet = new char [100];
    156   strcpy(info->fileOnNet, "http://www.orxonox.ethz.ch/files/taskHorizon.at.bermuda-funk.ogg");
     158  strcpy(info->fileOnNet, "http://www.orxonox.ethz.ch/files/02%20orxonox%203.mp3");
    157159  info->Bar = (ProgressBar*)bar;
    158160  PRINTF(3)("Preparing to download file %s.\n", info->fileOnNet);
    159   //downloadThread (info);
    160 
    161   if (!g_thread_create(&downloadThread, info, FALSE, NULL) != 0)
    162     PRINTF(1)("can't create the thread");
     161  //  downloadThread (info);
     162
     163  if (downloadThreadID == NULL)
     164    {
     165        if ( (downloadThreadID =g_thread_create(&downloadThread, info, TRUE, NULL)) == 0 )
     166          PRINTF(1)("can't create the thread");
     167    }
     168  else
     169    PRINTF(1)("thread already in use\n");
     170
    163171}
    164172
     
    191199int OrxonoxGuiUpdate::curlProgressFunc (ProgressBar* Bar, double totalSize, double progress, double upTotal, double upProgress)
    192200{
    193   //  gdk_threads_enter();
     201  gdk_threads_enter();
    194202  Bar->setProgress(progress);
    195203  Bar->setTotalSize(totalSize);
    196   //  gdk_threads_leave();
     204  gdk_threads_leave();
    197205  return 0;
    198206
    199207}
    200208
     209GThread* OrxonoxGuiUpdate::downloadThreadID = NULL;
     210
    201211void* OrxonoxGuiUpdate::downloadThread (void* fileInfo)
    202212{
     213 
    203214  PRINTF(3)("Downloading.\n");
    204215  FileInfo* info = (FileInfo*)fileInfo;
     
    225236      curl_easy_cleanup(curl);
    226237    }
     238  downloadThreadID = NULL;
    227239  return NULL;
    228240}
  • orxonox/branches/updater/src/gui/orxonox_gui_update.h

    r3263 r3266  
    5050  static int curlProgressFunc (ProgressBar* Bar, double totalSize, double progress, double upTotal, double upProgress);
    5151
     52  static GThread* downloadThreadID;
    5253  static void* downloadThread (void* fileInfo);
    5354 
Note: See TracChangeset for help on using the changeset viewer.