This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
question about "new" overloading function - one more
- From: "Tony Ko" <nhko at gctsemi dot com>
- To: <ecos-discuss at sources dot redhat dot com>
- Date: Wed, 6 Mar 2002 23:03:39 +0900
- Subject: [ECOS] question about "new" overloading function - one more
Hi.
Look at code below, this code is from thread.cxx.
// ---------------------------------------------------------------------
----
// Magic new operator to allow the thread constructor to be
// recalled.
inline void *
operator new(size_t size, Cyg_Thread *ptr)
{ return (void *)ptr; };
void
Cyg_Thread::reinitialize()
{
CYG_REPORT_FUNCTION();
CYG_ASSERTCLASS( this, "Bad thread");
CYG_ASSERT( this != Cyg_Scheduler::get_current_thread(),
"Attempt to reinitialize current thread");
CYG_ASSERT( get_current_queue() == NULL , "Thread is still on a
queue");
#ifdef CYGFUN_KERNEL_THREADS_TIMER
// Clear the timeout. It is irrelevant whether there was
// actually a timeout pending.
timer.disable();
#endif
// Ensure the scheduler has let go of us.
Cyg_Scheduler::scheduler.deregister_thread(this);
cyg_priority pri = get_priority();
#ifdef CYGVAR_KERNEL_THREADS_NAME
char * name_arg = name;
#else
char * name_arg = NULL;
#endif
new(this) Cyg_Thread( pri,
entry_point, entry_data,
name_arg,
get_stack_base(), get_stack_size() );
// the constructor re-registers the thread with the scheduler.
CYG_ASSERTCLASS( this, "Thread corrupted by reinitialize");
CYG_REPORT_RETURN();
}
I wonder about HOW this "new" operate.
thanks in advance
Tony (Nohi Ko)
_ _
GCT, Goodmorning Tower,Youido,Seoul,Korea. Tel:+82-2-2167-1283
Mobile : 016-368-7742 URL: www.gctsemi.com
You already possess everything necessary to become great. Crow
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss