Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3271 in orxonox.OLD for orxonox/branches/updater/src


Ignore:
Timestamp:
Dec 24, 2004, 6:29:38 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: threads are cool after all. trying again.

Location:
orxonox/branches/updater/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/Makefile.in

    r3268 r3271  
    127127EGREP = @EGREP@
    128128EXEEXT = @EXEEXT@
     129GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
     130GTHREAD_LIBS = @GTHREAD_LIBS@
    129131GTK2_CFLAGS = @GTK2_CFLAGS@
    130132GTK2_LIBS = @GTK2_LIBS@
    131133HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
    132134HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
     135HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
     136HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
    133137HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
    134138HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
  • orxonox/branches/updater/src/console/Makefile.in

    r3268 r3271  
    104104EGREP = @EGREP@
    105105EXEEXT = @EXEEXT@
     106GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
     107GTHREAD_LIBS = @GTHREAD_LIBS@
    106108GTK2_CFLAGS = @GTK2_CFLAGS@
    107109GTK2_LIBS = @GTK2_LIBS@
    108110HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
    109111HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
     112HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
     113HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
    110114HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
    111115HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
  • orxonox/branches/updater/src/gui/Makefile.am

    r3268 r3271  
    1 AM_CXXFLAGS=$(GTK2_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
    2 #AM_LDFLAGS=$(GTK2_LIBS)
    3 LIBS=$(GTK2_LIBS) $(CURL_LIBS)
     1AM_CXXFLAGS=$(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
     2#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
     3LIBS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    44
    55bin_PROGRAMS=gui
  • orxonox/branches/updater/src/gui/Makefile.in

    r3268 r3271  
    113113EGREP = @EGREP@
    114114EXEEXT = @EXEEXT@
     115GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
     116GTHREAD_LIBS = @GTHREAD_LIBS@
    115117GTK2_CFLAGS = @GTK2_CFLAGS@
    116118GTK2_LIBS = @GTK2_LIBS@
    117119HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
    118120HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
     121HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
     122HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
    119123HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
    120124HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
     
    125129LDFLAGS = @LDFLAGS@
    126130LIBOBJS = @LIBOBJS@
    127 #AM_LDFLAGS=$(GTK2_LIBS)
    128 LIBS = $(GTK2_LIBS) $(CURL_LIBS)
     131#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
     132LIBS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    129133LTLIBOBJS = @LTLIBOBJS@
    130134MAKEINFO = @MAKEINFO@
     
    184188target_os = @target_os@
    185189target_vendor = @target_vendor@
    186 AM_CXXFLAGS = $(GTK2_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
     190AM_CXXFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS)
    187191gui_SOURCES = orxonox_gui.cc \
    188192            orxonox_gui_gtk.cc \
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3268 r3271  
    4747bool initGTK(int argc, char *argv[])
    4848{
     49#ifdef HAVE_GTHREAD
     50  PRINTF(3)("Initializing the ThreadSystem of the GUI\n");
     51  g_thread_init(NULL);
     52  gdk_threads_init();
     53#endif /* HAVE_GTHREAD */
    4954  gtk_init (&argc, &argv);
    5055  gtk_rc_parse( "rc" );
     
    5661bool mainloopGTK(void)
    5762{
    58   PRINTF(1)("test\n");
     63  gdk_threads_enter();
    5964  gtk_main();
     65  gdk_threads_leave();
    6066}
    6167#endif /* HAVE_GTK2 */
     
    12031209    this->progress = this->totalSize;
    12041210
    1205 
    12061211#ifdef HAVE_GTK2
    12071212  gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize);
    1208   while (gtk_events_pending())
    1209     gtk_main_iteration_do(TRUE);
    12101213#endif /* HAVE_GTK2 */
    12111214  PRINTF(3)("Progress: %f\n", progress*100.0/totalSize);
  • orxonox/branches/updater/src/gui/orxonox_gui_update.cc

    r3270 r3271  
    9090#ifdef HAVE_GTK2
    9191  updateDataWindowButton->connectSignal("button_press_event", updateDataWindow, Window::windowOpen);
    92   updateDataWindow->connectSignal("destroy", updateDataWindow, cancelDownload);
    93   updateDataWindow->connectSignal("delete_event", updateDataWindow, cancelDownload);
     92  updateDataWindow->connectSignal("destroy", updateDataWindow, Window::windowClose);
     93  updateDataWindow->connectSignal("delete_event", updateDataWindow, Window::windowClose);
    9494#endif /* HAVE_GTK2 */
    9595
     
    149149  FileInfo* info = new FileInfo;
    150150
    151   info->fileName = "03%20orxonox%203'.mp3";
     151  info->fileName = "02%20orxonox%203.mp3";
    152152  info->webRoot  = "http://www.orxonox.ethz.ch/files/";
    153153  info->localRoot = "./";
    154154  info->Bar = (ProgressBar*)bar;
    155155  PRINTF(3)("Preparing to download file %s.\n", info->fileName);
    156   download(info);
     156  download (info);
     157  /*
     158  if (downloadThreadID == NULL)
     159    {
     160      if ( (downloadThreadID =g_thread_create(&downloadThread, info, TRUE, NULL)) == 0 )
     161        PRINTF(1)("can't create the thread");
     162    }
     163  else
     164  PRINTF(1)("thread already in use\n");
     165  */
    157166}
    158167
     
    188197  Bar->setTotalSize(totalSize);
    189198  return 0;
     199
    190200}
    191201
    192202CURL* OrxonoxGuiUpdate::curlHandle = NULL;
     203GThread* OrxonoxGuiUpdate::downloadThreadID = NULL;
    193204
    194205void* OrxonoxGuiUpdate::download (void* fileInfo)
     
    209220  if(curlHandle)
    210221    {
     222     
    211223      outfile = fopen(fileOnDisk, "w");
    212      
     224
    213225      curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet);
    214226      curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, outfile);
     
    218230      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSFUNCTION, curlProgressFunc);
    219231      curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->Bar);
     232
     233      if (!downloadThreadID)
     234        {
     235          //! \todo check if threads really were created.
     236          downloadThreadID = g_thread_create(&downloadThread, info, TRUE, NULL);
     237
     238          g_thread_create(&downloadThreadFinished, outfile, TRUE, NULL);
     239        }
     240      else
     241        PRINTF(1)("thread already in use\n");
     242      //      res = curl_easy_perform(curlHandle);
    220243     
    221       res = curl_easy_perform(curlHandle);
    222      
    223       fclose(outfile);
    224       if (curlHandle)
    225         curl_easy_cleanup(curlHandle);
     244      //      fclose(outfile);
    226245    }
     246  //  downloadThreadID = NULL;
    227247  return NULL;
     248}
     249void* OrxonoxGuiUpdate::downloadThread(void* fileInfo)
     250{
     251  //  gdk_threads_enter();
     252  curl_easy_perform(curlHandle);
     253  if (curlHandle)
     254    curl_easy_cleanup(curlHandle);
     255  gdk_threads_leave();
     256  downloadThreadID = NULL;
     257  //  g_thread_exit (NULL);
     258}
     259
     260void* OrxonoxGuiUpdate::downloadThreadFinished(void* outfile)
     261{
     262  g_thread_join(downloadThreadID);
     263  PRINTF(3)("Closing the downloaded file.\n");
     264  fclose((FILE*)outfile);
    228265}
    229266
  • orxonox/branches/updater/src/gui/orxonox_gui_update.h

    r3270 r3271  
    5959
    6060  static CURL* curlHandle;
    61   static void* download (void* fileInfo);
    6261#ifdef HAVE_GTK2
    6362  static gint cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar);
    6463#endif /* HAVE_GTK2 */ 
     64  static GThread* downloadThreadID;
     65  static void* download (void* fileInfo);
     66  static void* downloadThread (void* fileInfo);
     67  static void* downloadThreadFinished(void* outfile);
     68
     69 
    6570#endif /* HAVE_CURL */
    6671
  • orxonox/branches/updater/src/importer/Makefile.in

    r3268 r3271  
    105105EGREP = @EGREP@
    106106EXEEXT = @EXEEXT@
     107GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
     108GTHREAD_LIBS = @GTHREAD_LIBS@
    107109GTK2_CFLAGS = @GTK2_CFLAGS@
    108110GTK2_LIBS = @GTK2_LIBS@
    109111HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
    110112HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
     113HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
     114HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
    111115HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
    112116HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
Note: See TracChangeset for help on using the changeset viewer.