Boost logo

Boost Users :

From: Bruno Martínez (br1_at_[hidden])
Date: 2005-09-21 14:21:21


On Wed, 21 Sep 2005 15:39:35 -0300, Simmons, Aaron <a-simmons1_at_[hidden]>
wrote:

> I write a lot of cross-platform code that's used from JNI. In JNI, you
> should tell the JVM about native threads that are running. Because Java
> threads are named, when you attach a native thread to the JVM you have
> to specify a name.
>
> It occurred to me that I could write a "jnithread" class that inherits
> from boost::thread. It would take a thread-name argument. Before the
> threadfunc runs it would attach the new thread to the JVM, and when the
> threadfunc ends it would detach from the JVM.

Why don't you write an adapter that takes a nullary function and calls it
between attaches/dettaches.

The syntax of creating a thread would then be:

void worker_func(int i);

thread mythread( jniadapt("mythread", bind(worker_func, 55)) );

Bruno


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net