[ace-users] Help to use thread_manager
Steve Huston
shuston at riverace.com
Mon Jun 25 11:45:40 CDT 2007
Hi Jeong,
Thank you for using the PROBLEM-REPORT-FORM.
Did you link your application with ACE_wrappers/lib/ACE.lib (or
ACEd.lib)?
-Steve
--
Steve Huston, Riverace Corporation
Would you like ACE to run great on your platform?
See http://www.riverace.com/sponsor.htm
> -----Original Message-----
> From: ace-users-bounces at cse.wustl.edu
> [mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Jeong Ho Lee
> Sent: Monday, June 25, 2007 7:14 AM
> To: ace-users at cs.wustl.edu
> Subject: [ace-users] Help to use thread_manager
>
>
> ACE Version: 5.5.8
> Host machine and Operating System:
> Intel Core2 1.5GB, XP Pro SP2
> Target Machine and Operating System:
> same
> config.h FILE
> #define ACE_HAS_STANDARD_CPP_LIBRARY 1
> #define ACE_HAS_MFC 1
> #define ACE_NO_INLINE
> #include "ace/config-win32.h"
>
> MSVC++, Visual Studio 2005
>
> AREA/CLASS/EXAMPLE AFFECTED:
> Thread, Thread_Manager
>
> DOES THE PROBLEM AFFECT:
> COMPILATION? no
> LINKING? yes
> EXECUTION? no
>
>
> DESCRIPTION:
> I try to learn how to write a thread-based application baesd
on
> the Thread_Manager Class. However, I cannot compile
> my simple program with link errors.
>
> The errors I got are written below
> 1. error LNK2019: "__declspec(dllimport) public: int __thiscall
> ACE_Thread_Manager::spawn(unsigned long (__cdecl*)(void *),void
> *,long,unsigned long *,void * *,long,int,void *,unsigned int)"
> (__imp_?spawn at ACE_Thread_Manager@@QAEHP6AKPAX at Z0JPAKPAPAXJH0I@Z)
> ... Thread.obj
> 2. error LNK2019: "__declspec(dllimport) public: static class
> ACE_Thread_Manager * __cdecl ACE_Thread_Manager::instance(void)"
> (__imp_?instance at ACE_Thread_Manager@@SAPAV1 at XZ) ... Thread.obj
>
> My simple program is
>
> ================================================================
> Thread.h
> ================================================================
> #pragma once
>
> class CThread
> {
> public:
> CThread(void);
> public:
> ~CThread(void);
>
> private:
> class Thread_Args
> {
> public:
> Thread_Args(unsigned short id, CThread* lsp) :
> id_(id), this_(lsp) {}
> CThread* this_;
> unsigned short id_;
> };
>
> static void* run_svc (void* arg);
>
> public:
> void start(unsigned short);
> };
> ================================================================
> Thread.cpp
> ================================================================
> #include "StdAfx.h"
> #include "Thread.h"
> #include <iostream>
>
> #include "ace/Basic_Types.h"
> #include "ace/Thread_Manager.h"
> #include "ace/Log_Msg.h"
>
> using namespace std;
>
> CThread::CThread(void)
> {
> }
>
> CThread::~CThread(void)
> {
> }
>
> void* CThread::run_svc(void* arg)
> {
> Thread_Args *thread_args = ACE_static_cast(Thread_Args*, arg);
>
> for(int i = 0; i < thread_args->id_; i++)
> cout << thread_args->id_ << " is running" << endl;
>
> delete thread_args;
> return 0;
> }
>
> void CThread::start(unsigned short id)
> {
> Thread_Args *thread_args = new Thread_Args(id, this);
> ACE_Thread_Manager::instance()->spawn((ACE_THR_FUNC)run_svc,
> ACE_static_cast(void*, thread_args), THR_DETACHED |
THR_SCOPE_SYSTEM);
> }
> ================================================================
> testthread.cpp
> ================================================================
> // testthread.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
> //
>
> #include "stdafx.h"
> #include "Thread.h"
>
> int main(int argc, char* argv[])
> {
> CThread* pthread[100];
> for(int i = 0; i < 100; i++)
> {
> pthread[i] = new CThread();
> pthread[i]->start(i);
> }
>
>
> return 0;
> }
>
> Please give me any clue that I can solve this problem.
> Thanks.
>
> - Jeong Ho
> _______________________________________________
> ace-users mailing list
> ace-users at mail.cse.wustl.edu
> http://mail.cse.wustl.edu/mailman/listinfo/ace-users
>
More information about the Ace-users
mailing list