Advertisement
Guest User

dvyukov

a guest
Jul 16th, 2009
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct msg_connect : msg<msg_connect>
  2. {
  3.     string      addr;
  4.     uint16_t    port;
  5. };
  6.  
  7. struct msg_send_packet : msg<msg_send_packet>
  8. {
  9.     void*       data;
  10.     size_t      size;
  11. };
  12.  
  13. class socket : public agent<socket>
  14. {
  15.     void on_event(event_t<msg_connect> ev)
  16.     {
  17.     }
  18.  
  19.     void on_event(event_t<msg_send_packet> ev)
  20.     {
  21.     }
  22. };
  23.  
  24.  
  25. socket::handle s = socket::create(...);
  26. s->send(msg_connect::create("localhost", 80));
  27. s->send(msg_send_packet::create(&data[0] data.size());
  28.  
  29.  
  30. class form
  31. {
  32.     void on_event(join_event<msg_db_load_ack, msg_show> ev)
  33.     {
  34.         // activated when both messages arrive
  35.     }
  36. };
  37.  
  38. class form
  39. {
  40.     void on_event(read_event<msg_get_info> ev) const
  41.     {
  42.         // can be executed concurrently with other read_events
  43.     }
  44. };
  45.  
Advertisement
RAW Paste Data Copied
Advertisement