Changeset 988 for vendor/current/lib/tevent/tevent.h
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/tevent/tevent.h
r740 r988 40 40 struct tevent_immediate; 41 41 struct tevent_signal; 42 struct tevent_thread_proxy; 42 43 43 44 /** … … 112 113 113 114 /** 114 * @brief Create a event_context structure and name it.115 * @brief Create a event_context structure and select a specific backend. 115 116 * 116 117 * This must be the first events call, and all subsequent calls pass this … … 120 121 * @param[in] mem_ctx The memory context to use. 121 122 * 122 * @param[in] name The name for the tevent context.123 * @param[in] name The name of the backend to use. 123 124 * 124 125 * @return An allocated tevent context, NULL on error. 125 126 */ 126 127 struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name); 128 129 /** 130 * @brief Create a custom event context 131 * 132 * @param[in] mem_ctx The memory context to use. 133 * @param[in] ops The function pointer table of the backend. 134 * @param[in] additional_data The additional/private data to this instance 135 * 136 * @return An allocated tevent context, NULL on error. 137 * 138 */ 139 struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx, 140 const struct tevent_ops *ops, 141 void *additional_data); 127 142 128 143 /** … … 137 152 138 153 /** 139 * @brief Set the default tevent backen t.154 * @brief Set the default tevent backend. 140 155 * 141 156 * @param[in] backend The name of the backend to set. … … 163 178 * @note To cancel the monitoring of a file descriptor, call talloc_free() 164 179 * on the object returned by this function. 180 * 181 * @note The caller should avoid closing the file descriptor before 182 * calling talloc_free()! Otherwise the behaviour is undefined which 183 * might result in crashes. See https://bugzilla.samba.org/show_bug.cgi?id=11141 184 * for an example. 165 185 */ 166 186 struct tevent_fd *tevent_add_fd(struct tevent_context *ev, … … 306 326 * @note To cancel a signal handler, call talloc_free() on the event returned 307 327 * from this function. 328 * 329 * @see tevent_num_signals, tevent_sa_info_queue_count 308 330 */ 309 331 struct tevent_signal *tevent_add_signal(struct tevent_context *ev, … … 327 349 #endif 328 350 351 /** 352 * @brief the number of supported signals 353 * 354 * This returns value of the configure time TEVENT_NUM_SIGNALS constant. 355 * 356 * The 'signum' argument of tevent_add_signal() must be less than 357 * TEVENT_NUM_SIGNALS. 358 * 359 * @see tevent_add_signal 360 */ 361 size_t tevent_num_signals(void); 362 363 /** 364 * @brief the number of pending realtime signals 365 * 366 * This returns value of TEVENT_SA_INFO_QUEUE_COUNT. 367 * 368 * The tevent internals remember the last TEVENT_SA_INFO_QUEUE_COUNT 369 * siginfo_t structures for SA_SIGINFO signals. If the system generates 370 * more some signals get lost. 371 * 372 * @see tevent_add_signal 373 */ 374 size_t tevent_sa_info_queue_count(void); 375 329 376 #ifdef DOXYGEN 330 377 /** … … 502 549 int tevent_set_debug_stderr(struct tevent_context *ev); 503 550 551 enum tevent_trace_point { 552 /** 553 * Corresponds to a trace point just before waiting 554 */ 555 TEVENT_TRACE_BEFORE_WAIT, 556 /** 557 * Corresponds to a trace point just after waiting 558 */ 559 TEVENT_TRACE_AFTER_WAIT, 560 #define TEVENT_HAS_LOOP_ONCE_TRACE_POINTS 1 561 /** 562 * Corresponds to a trace point just before calling 563 * the loop_once() backend function. 564 */ 565 TEVENT_TRACE_BEFORE_LOOP_ONCE, 566 /** 567 * Corresponds to a trace point right after the 568 * loop_once() backend function has returned. 569 */ 570 TEVENT_TRACE_AFTER_LOOP_ONCE, 571 }; 572 573 typedef void (*tevent_trace_callback_t)(enum tevent_trace_point, 574 void *private_data); 575 576 /** 577 * Register a callback to be called at certain trace points 578 * 579 * @param[in] ev Event context 580 * @param[in] cb Trace callback 581 * @param[in] private_data Data to be passed to callback 582 * 583 * @note The callback will be called at trace points defined by 584 * tevent_trace_point. Call with NULL to reset. 585 */ 586 void tevent_set_trace_callback(struct tevent_context *ev, 587 tevent_trace_callback_t cb, 588 void *private_data); 589 590 /** 591 * Retrieve the current trace callback 592 * 593 * @param[in] ev Event context 594 * @param[out] cb Registered trace callback 595 * @param[out] private_data Registered data to be passed to callback 596 * 597 * @note This can be used to allow one component that wants to 598 * register a callback to respect the callback that another component 599 * has already registered. 600 */ 601 void tevent_get_trace_callback(struct tevent_context *ev, 602 tevent_trace_callback_t *cb, 603 void *private_data); 604 504 605 /** 505 606 * @} … … 517 618 * are considered too low-level to be used in larger computations. To 518 619 * read and write from and to sockets, Samba provides two calls on top 519 * of tevent_add_fd: read_packet_send/recv and writev_send/recv. These520 * requests are much easier to compose than the low-level event620 * of tevent_add_fd: tstream_read_packet_send/recv and tstream_writev_send/recv. 621 * These requests are much easier to compose than the low-level event 521 622 * handlers called from tevent_add_fd. 522 623 * … … 840 941 #endif 841 942 943 /** 944 * @brief A typedef for a cleanup function for a tevent request. 945 * 946 * @param[in] req The tevent request calling this function. 947 * 948 * @param[in] req_state The current tevent_req_state. 949 * 950 */ 951 typedef void (*tevent_req_cleanup_fn)(struct tevent_req *req, 952 enum tevent_req_state req_state); 953 954 /** 955 * @brief This function sets a cleanup function for the given tevent request. 956 * 957 * This function can be used to setup a cleanup function for the given request. 958 * This will be triggered when the tevent_req_done() or tevent_req_error() 959 * function was called, before notifying the callers callback function, 960 * and also before scheduling the deferred trigger. 961 * 962 * This might be useful if more than one tevent_req belong together 963 * and need to finish both requests at the same time. 964 * 965 * The cleanup function is able to call tevent_req_done() or tevent_req_error() 966 * recursively, the cleanup function is only triggered the first time. 967 * 968 * The cleanup function is also called by tevent_req_received() 969 * (possibly triggered from tevent_req_destructor()) before destroying 970 * the private data of the tevent_req. 971 * 972 * @param[in] req The request to use. 973 * 974 * @param[in] fn A pointer to the cancel function. 975 */ 976 void tevent_req_set_cleanup_fn(struct tevent_req *req, tevent_req_cleanup_fn fn); 977 842 978 #ifdef DOXYGEN 843 979 /** … … 852 988 * @endcode 853 989 * 854 * Tevent_req_create() creates the state variable as a talloc child of855 * its result. The state variable should be used as the talloc parent856 * for all temporary variables that are allocated during the async990 * Tevent_req_create() allocates and zeros the state variable as a talloc 991 * child of its result. The state variable should be used as the talloc 992 * parent for all temporary variables that are allocated during the async 857 993 * computation. This way, when the user of the async computation frees 858 994 * the request, the state as a talloc child will be free'd along with … … 996 1132 #endif 997 1133 1134 #ifdef DOXYGEN 1135 /** 1136 * @brief Indicate out of memory to a request 1137 * 1138 * @param[in] req The request being processed. 1139 */ 1140 void tevent_req_oom(struct tevent_req *req); 1141 #else 1142 void _tevent_req_oom(struct tevent_req *req, 1143 const char *location); 1144 #define tevent_req_oom(req) \ 1145 _tevent_req_oom(req, __location__) 1146 #endif 1147 998 1148 /** 999 1149 * @brief Finish a request before the caller had the change to set the callback. … … 1003 1153 * the engine. To present the illusion of a callback to the user of the API, 1004 1154 * the implementation can call this helper function which triggers an 1005 * immediate timedevent. This way the caller can use the same calling1155 * immediate event. This way the caller can use the same calling 1006 1156 * conventions, independent of whether the request was actually deferred. 1007 1157 * … … 1027 1177 * @param[in] req The finished request. 1028 1178 * 1029 * @param[in] ev The tevent_context for the timedevent.1179 * @param[in] ev The tevent_context for the immediate event. 1030 1180 * 1031 1181 * @return The given request will be returned. … … 1033 1183 struct tevent_req *tevent_req_post(struct tevent_req *req, 1034 1184 struct tevent_context *ev); 1185 1186 /** 1187 * @brief Finish multiple requests within one function 1188 * 1189 * Normally tevent_req_notify_callback() and all wrappers 1190 * (e.g. tevent_req_done() and tevent_req_error()) 1191 * need to be the last thing an event handler should call. 1192 * This is because the callback is likely to destroy the 1193 * context of the current function. 1194 * 1195 * If a function wants to notify more than one caller, 1196 * it is dangerous if it just triggers multiple callbacks 1197 * in a row. With tevent_req_defer_callback() it is possible 1198 * to set an event context that will be used to defer the callback 1199 * via an immediate event (similar to tevent_req_post()). 1200 * 1201 * @code 1202 * struct complete_state { 1203 * struct tevent_context *ev; 1204 * 1205 * struct tevent_req **reqs; 1206 * }; 1207 * 1208 * void complete(struct complete_state *state) 1209 * { 1210 * size_t i, c = talloc_array_length(state->reqs); 1211 * 1212 * for (i=0; i < c; i++) { 1213 * tevent_req_defer_callback(state->reqs[i], state->ev); 1214 * tevent_req_done(state->reqs[i]); 1215 * } 1216 * } 1217 * @endcode 1218 * 1219 * @param[in] req The finished request. 1220 * 1221 * @param[in] ev The tevent_context for the immediate event. 1222 * 1223 * @return The given request will be returned. 1224 */ 1225 void tevent_req_defer_callback(struct tevent_req *req, 1226 struct tevent_context *ev); 1035 1227 1036 1228 /** … … 1219 1411 * @param[in] secs The seconds to set. 1220 1412 * 1221 * @param[in] usecs The mi lliseconds to set.1413 * @param[in] usecs The microseconds to set. 1222 1414 * 1223 1415 * @return A timeval structure with the given values. … … 1254 1446 * @param[in] secs The seconds to add to the timeval. 1255 1447 * 1256 * @param[in] usecs The mi lliseconds to add to the timeval.1448 * @param[in] usecs The microseconds to add to the timeval. 1257 1449 * 1258 1450 * @return The timeval structure with the new time. … … 1266 1458 * @param[in] secs The seconds of the offset from now. 1267 1459 * 1268 * @param[in] usecs The mi lliseconds of the offset from now.1460 * @param[in] usecs The microseconds of the offset from now. 1269 1461 * 1270 1462 * @return A timval with the given offset in the future. … … 1292 1484 1293 1485 struct tevent_queue; 1486 struct tevent_queue_entry; 1294 1487 1295 1488 #ifdef DOXYGEN … … 1303 1496 * @return An allocated tevent queue on success, NULL on error. 1304 1497 * 1305 * @see tevent_ start()1306 * @see tevent_ stop()1498 * @see tevent_queue_start() 1499 * @see tevent_queue_stop() 1307 1500 */ 1308 1501 struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx, … … 1326 1519 * 1327 1520 * @see tevent_queue_add() 1521 * @see tevent_queue_add_entry() 1522 * @see tevent_queue_add_optimize_empty() 1328 1523 */ 1329 1524 typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req, … … 1340 1535 * 1341 1536 * @param[in] trigger The function triggered by the queue when the request 1342 * is called. 1537 * is called. Since tevent 0.9.14 it's possible to 1538 * pass NULL, in order to just add a "blocker" to the 1539 * queue. 1343 1540 * 1344 1541 * @param[in] private_data The private data passed to the trigger function. … … 1354 1551 1355 1552 /** 1553 * @brief Add a tevent request to the queue. 1554 * 1555 * The request can be removed from the queue by calling talloc_free() 1556 * (or a similar function) on the returned queue entry. This 1557 * is the only difference to tevent_queue_add(). 1558 * 1559 * @param[in] queue The queue to add the request. 1560 * 1561 * @param[in] ev The event handle to use for the request. 1562 * 1563 * @param[in] req The tevent request to add to the queue. 1564 * 1565 * @param[in] trigger The function triggered by the queue when the request 1566 * is called. Since tevent 0.9.14 it's possible to 1567 * pass NULL, in order to just add a "blocker" to the 1568 * queue. 1569 * 1570 * @param[in] private_data The private data passed to the trigger function. 1571 * 1572 * @return a pointer to the tevent_queue_entry if the request 1573 * has been successfully added, NULL otherwise. 1574 * 1575 * @see tevent_queue_add() 1576 * @see tevent_queue_add_optimize_empty() 1577 */ 1578 struct tevent_queue_entry *tevent_queue_add_entry( 1579 struct tevent_queue *queue, 1580 struct tevent_context *ev, 1581 struct tevent_req *req, 1582 tevent_queue_trigger_fn_t trigger, 1583 void *private_data); 1584 1585 /** 1586 * @brief Add a tevent request to the queue using a possible optimization. 1587 * 1588 * This tries to optimize for the empty queue case and may calls 1589 * the trigger function directly. This is the only difference compared 1590 * to tevent_queue_add_entry(). 1591 * 1592 * The caller needs to be prepared that the trigger function has 1593 * already called tevent_req_notify_callback(), tevent_req_error(), 1594 * tevent_req_done() or a similar function. 1595 * 1596 * The request can be removed from the queue by calling talloc_free() 1597 * (or a similar function) on the returned queue entry. 1598 * 1599 * @param[in] queue The queue to add the request. 1600 * 1601 * @param[in] ev The event handle to use for the request. 1602 * 1603 * @param[in] req The tevent request to add to the queue. 1604 * 1605 * @param[in] trigger The function triggered by the queue when the request 1606 * is called. Since tevent 0.9.14 it's possible to 1607 * pass NULL, in order to just add a "blocker" to the 1608 * queue. 1609 * 1610 * @param[in] private_data The private data passed to the trigger function. 1611 * 1612 * @return a pointer to the tevent_queue_entry if the request 1613 * has been successfully added, NULL otherwise. 1614 * 1615 * @see tevent_queue_add() 1616 * @see tevent_queue_add_entry() 1617 */ 1618 struct tevent_queue_entry *tevent_queue_add_optimize_empty( 1619 struct tevent_queue *queue, 1620 struct tevent_context *ev, 1621 struct tevent_req *req, 1622 tevent_queue_trigger_fn_t trigger, 1623 void *private_data); 1624 1625 /** 1356 1626 * @brief Start a tevent queue. 1357 1627 * … … 1379 1649 */ 1380 1650 size_t tevent_queue_length(struct tevent_queue *queue); 1651 1652 /** 1653 * @brief Is the tevent queue running. 1654 * 1655 * The queue is started by default. 1656 * 1657 * @param[in] queue The queue. 1658 * 1659 * @return Wether the queue is running or not.. 1660 */ 1661 bool tevent_queue_running(struct tevent_queue *queue); 1662 1663 /** 1664 * @brief Create a tevent subrequest that waits in a tevent_queue 1665 * 1666 * The idea is that always the same syntax for tevent requests. 1667 * 1668 * @param[in] mem_ctx The talloc memory context to use. 1669 * 1670 * @param[in] ev The event handle to setup the request. 1671 * 1672 * @param[in] queue The queue to wait in. 1673 * 1674 * @return The new subrequest, NULL on error. 1675 * 1676 * @see tevent_queue_wait_recv() 1677 */ 1678 struct tevent_req *tevent_queue_wait_send(TALLOC_CTX *mem_ctx, 1679 struct tevent_context *ev, 1680 struct tevent_queue *queue); 1681 1682 /** 1683 * @brief Check if we no longer need to wait in the queue. 1684 * 1685 * This function needs to be called in the callback function set after calling 1686 * tevent_queue_wait_send(). 1687 * 1688 * @param[in] req The tevent request to check. 1689 * 1690 * @return True on success, false otherwise. 1691 * 1692 * @see tevent_queue_wait_send() 1693 */ 1694 bool tevent_queue_wait_recv(struct tevent_req *req); 1381 1695 1382 1696 typedef int (*tevent_nesting_hook)(struct tevent_context *ev, … … 1386 1700 void *stack_ptr, 1387 1701 const char *location); 1702 1703 /** 1704 * @brief Create a tevent_thread_proxy for message passing between threads. 1705 * 1706 * The tevent_context must have been allocated on the NULL 1707 * talloc context, and talloc_disable_null_tracking() must 1708 * have been called. 1709 * 1710 * @param[in] dest_ev_ctx The tevent_context to receive events. 1711 * 1712 * @return An allocated tevent_thread_proxy, NULL on error. 1713 * If tevent was compiled without PTHREAD support 1714 * NULL is always returned and errno set to ENOSYS. 1715 * 1716 * @see tevent_thread_proxy_schedule() 1717 */ 1718 struct tevent_thread_proxy *tevent_thread_proxy_create( 1719 struct tevent_context *dest_ev_ctx); 1720 1721 /** 1722 * @brief Schedule an immediate event on an event context from another thread. 1723 * 1724 * Causes dest_ev_ctx, being run by another thread, to receive an 1725 * immediate event calling the handler with the *pp_private parameter. 1726 * 1727 * *pp_im must be a pointer to an immediate event talloced on a context owned 1728 * by the calling thread, or the NULL context. Ownership will 1729 * be transferred to the tevent_thread_proxy and *pp_im will be returned as NULL. 1730 * 1731 * *pp_private_data must be a talloced area of memory with no destructors. 1732 * Ownership of this memory will be transferred to the tevent library and 1733 * *pp_private_data will be set to NULL on successful completion of 1734 * the call. Set pp_private to NULL if no parameter transfer 1735 * needed (a pure callback). This is an asynchronous request, caller 1736 * does not wait for callback to be completed before returning. 1737 * 1738 * @param[in] tp The tevent_thread_proxy to use. 1739 * 1740 * @param[in] pp_im Pointer to immediate event pointer. 1741 * 1742 * @param[in] handler The function that will be called. 1743 * 1744 * @param[in] pp_private_data The talloced memory to transfer. 1745 * 1746 * @see tevent_thread_proxy_create() 1747 */ 1748 void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp, 1749 struct tevent_immediate **pp_im, 1750 tevent_immediate_handler_t handler, 1751 void *pp_private_data); 1752 1388 1753 #ifdef TEVENT_DEPRECATED 1389 1754 #ifndef _DEPRECATED_
Note:
See TracChangeset
for help on using the changeset viewer.