Boost logo

Boost :

From: Michael Glassford (glassfordm_at_[hidden])
Date: 2003-12-31 12:53:44

Roland wrote:

> Does anyone know if it is possible somehow to have a native
> Windows event variable signal a boost thread condition?

I believe the answer is that it's not possible (at least with the
current Boost.Thread library).

> I am trying to use the monitor pattern to make my port class
> thread safe. On entry to my read function I acquire the lock and
> then when it comes to wait for any data to receive I get
> in trouble. The condition should be awakened by the received
> data. Windows can do this by signaling an event variable, and
> one can wait on this via WaitForMultipleObjects.
> But I see no obvious way how this relates to my "condition" variable.

Because it doesn't, I should say.

> Should I simply unlock the mutex before entering WaitForMultipleObjects?

It's hard to say without knowing what exactly the mutex is protecting.
Perhaps you could post some sample code?

> There is no user accessible API for such an operation.

I'm not sure I understand this. You say you obtain the lock at the
beginning of the function; can't you simply use the lock object's
unlock() method? Or am I misunderstanding something. Again, sample code
might help.

> Is it ok to use locks on the heap in such a case?
> What is about race conditions in this case?

It's hard to comment on either of these without more details.

> Can anyone give me a hint of how to deal with other system-level
> blocking situations?
> Perhaps I am simply overlooking the obvious.
> Thank you,
> Roland


Boost list run by bdawes at, gregod at, cpdaniel at, john at