mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Cristian Ramirez <r.cristian.rami...@gmail.com>
Subject Controlling lock operation inside the session.write() method
Date Fri, 15 Feb 2013 21:20:28 GMT
I have a client application which has a sending state. If sending state is
enabled, this means client can send something to the server and if it is
disabled, client can not send  anything. Sending state is directed by
server, i.e. server sends a message "sending_enabled" and client's state
changes. And, when client's sending state is disabled, it should   not send
anything to the server.

Currently, I have a mina client application whose connector is
NioSocketConnector. On the client side, I use session.write() method for
sending data. However, in order to achieve the above situation, I have to
do some extra thing. Consider the below situation:

check the client state before sending -> assume that sending is enabled, so
we can send our data
call session.write(...) -> code inside the write() method is being executed
Now, assume that before locking the channel in the sender thread, it has
lost the processor. Then, receiver thread takes the processor and got a
message which says "sending_disabled". Hence, client's state is changed.
When the sender thread takes the processor again, our message will be sent
to the server without checking the client's       state. However, that
message should not send.

Briefly, I want to make a check when the session.write() method locks the
channel. Can I do this, how?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message