Objective-C에서 oneway keyword

retain과 release를 overriding 하려다 보니.. release에서 oneway라는 키워드가 보이네요. 다음과 같이 말이죠.

- (oneway void)release;

무슨 말인지 찾아보니 "The Objective-C 2.0 Programming Language" PDF 파일에

"Synchronous and Asynchronous Messages
Consider first a method with just a simple return value:
- (BOOL)canDance;
When a canDance message is sent to a receiver in the same application, the method is invoked and the
return value provided directly to the sender. But when the receiver is in a remote application, two underlying
messages are required—one message to get the remote object to invoke the method, and the other message
to send back the result of the remote calculation. This is illustrated in the figure below:
<Figure 12-2>
Most remote messages are, at bottom, two-way (or “round trip”) remote procedure calls (RPCs) like this one.
The sending application waits for the receiving application to invoke the method, complete its processing,
and send back an indication that it has finished, along with any return information requested. Waiting for
the receiver to finish, even if no information is returned, has the advantage of coordinating the two
communicating applications, of keeping them both “in sync.” For this reason, round-trip messages are often
called synchronous. Synchronous messages are the default.
However, it’s not always necessary or a good idea to wait for a reply. Sometimes it’s sufficient simply to
dispatch the remote message and return, allowing the receiver to get to the task when it can. In the meantime,
the sender can go on to other things. Objective-C provides a return type modifier, oneway, to indicate that
a method is used only for asynchronous messages:
- (oneway void)waltzAtWill;
Although oneway is a type qualifier (like const) and can be used in combination with a specific type name,
such as oneway float or oneway id, the only such combination that makes any sense is oneway void.
An asynchronous message can’t have a valid return value."

라고 되어 있습니다.

요 글에 의하면 일반적으로 Objective-c 에서 remote에 있는 receiver에게 message를 전달하는 방식은 synchronous 방식이라고 합니다. 즉, 메서드를 호출하면 return 결과를 받을 때 까지 멈춘다(blocking) 이거죠.
하지만 굳이 remote 호출 시 대기 할 필요가 없는 메서드는 asynchronous 하게 호출하도록 할 수 있습니다.
이럴 때 사용되는 keyword가 oneway이며, 위의 release와 같은 경우 asynchronous 하게 호출된다고 할 수 있겠습니다.

RPC를 통한 remote 호출을 해본적이 없어서 자세한 예는 들기 힘드네요. 나중에 호출해볼 수 있는 좋은 기회가 있었으면~
크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by 장현준

2009/08/27 16:56 2009/08/27 16:56
,
Response
No Trackback , No Comment
RSS :
http://b4you.net/blog/rss/response/244


블로그 이미지

빗소리를 먹는 사람.

- 장현준

Notices

Archives

Authors

  1. 장현준

Recent Trackbacks

  1. 듀얼클러치의 생각 rsvin28's me2DAY 2009

Calendar

«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Site Stats

Total hits:
158011
Today:
81
Yesterday:
228