Creating Boost.Asio extensions Boris Schäling, May 2011, www.highscore.de

How does Boost.Asio look like internally? What are I/O service objects, I/O services and I/O objects? How do I access platform-specific I/O sevices?

BoostCon 2011

Boost.Asio: Asynchronous functions void handler(const boost::system::error_code &ec) { } int main() { boost::asio::io_service io_service; boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5)); timer.async_wait(handler); io_service.run(); }

BoostCon 2011

Boost.Process: Process management in C++

2

Boost.Asio: Asynchronous functions boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5)); timer.async_wait(handler);

deadline_timer is one of many classes in Boost.Asio which make it possible to call functions asynchronously

Calling asynchronously means that async_wait() doesn‘t block – after the time expired the function is called which is passed as a parameter (here handler) BoostCon 2011

Boost.Process: Process management in C++

3

Boost.Asio: Asynchronous functions deadline_timer

async_wait() to wait until some time is expired

ip::tcp::acceptor

async_accept() to accept TCP/IP connections

ip::tcp::resolver

async_resolve() to resolve hostnames

ip::tcp::socket

async_read_some() and async_write_some() to send and receive data

Boost.Asio provides different classes which turn different blocking functions into asynchronous functions BoostCon 2011

Boost.Process: Process management in C++

4

Boost.Asio internals void handler(const boost::system::error_code &ec) { } int main() I/O service object { boost::asio::io_service io_service; boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5)); I/O object timer.async_wait(handler); io_service.run(); }

BoostCon 2011

Boost.Process: Process management in C++

5

Boost.Asio internals deadline_timer

io_service

An I/O object is initialized with an I/O service object. It doesn‘t use the I/O service object though – it uses services provided by the I/O service object.

An I/O service object provides services to I/O objects. Think of it as a set of services – set because there is maximum one instance of each and every service.

While I/O objects and I/O service objects are visible in user code, I/O services do the hard work in the background. BoostCon 2011

Boost.Process: Process management in C++

6

Boost.Asio internals I/O service A

I/O service B

I/O service object

I/O object 1

BoostCon 2011

I/O object 2

Boost.Process: Process management in C++

I/O object 3

7

Boost.Asio internals boost::asio:: stream_socket_service

boost::asio:: deadline_timer_service

boost::asio:: io_service

boost::asio::ip::tcp:: basic_stream_socket

BoostCon 2011

boost::asio::ip::tcp:: basic_socket_iostream

boost::asio:: basic_deadline_timer

Boost.Process: Process management in C++

8

Boost.Asio internals I/O services are based on system functions to provide a service to one or several I/O objects

I/O service A

I/O service B

I/O service object

I/O object 1

I/O object 2

I/O service objects manage and provide access to I/O services I/O object 3

I/O objects get a reference to an I/O service object when instantiated

BoostCon 2011

Boost.Process: Process management in C++

9

Boost.Asio internals Implementations of I/O services can be based on system APIspecific classes

boost::asio::detail:: win_iocp_io_service

boost::asio:: stream_socket_service

boost::asio:: deadline_timer_service

boost::asio:: io_service

boost::asio::ip::tcp:: basic_stream_socket

BoostCon 2011

boost::asio::ip::tcp:: basic_socket_iostream

boost::asio:: basic_deadline_timer

Boost.Process: Process management in C++

10

Boost.Asio internals boost::asio::detail:: win_iocp_io_service

boost::asio:: stream_socket_service

boost::asio:: deadline_timer_service

boost::asio:: datagram_socket_servic e

boost::asio:: basic_socket_streambuf

boost::asio::ip:: resolver_service

Not all I/O services share a system API-specific service

boost::asio:: socket_acceptor_servic e

BoostCon 2011

Boost.Process: Process management in C++

11

Boost.Asio internals boost::asio::detail:: win_iocp_io_service

boost::asio:: stream_socket_service

boost::asio:: deadline_timer_service

boost::asio::ip:: resolver_service

boost::asio:: io_service

boost::asio::ip::tcp:: basic_stream_socket

BoostCon 2011

boost::asio::ip::tcp:: basic_socket_iostream

boost::asio:: basic_deadline_timer

Boost.Process: Process management in C++

boost::asio::ip::tcp:: basic_resolver

12

Boost.Asio internals boost::asio::detail:: win_iocp_io_service

boost::asio:: stream_socket_service

boost::asio::windows:: overlapped_ptr

boost::asio:: deadline_timer_service

boost::asio::ip:: resolver_service

boost::asio:: io_service

boost::asio::ip::tcp:: basic_stream_socket

BoostCon 2011

boost::asio::ip::tcp:: basic_socket_iostream

boost::asio:: basic_deadline_timer

Boost.Process: Process management in C++

boost::asio::ip::tcp:: basic_resolver

13

Boost.Asio internals boost::asio::detail:: win_iocp_io_service

boost::asio:: deadline_timer_service

New service

boost::asio::windows:: overlapped_ptr

boost::asio:: io_service

Reuse a service

BoostCon 2011

Create a new service

Boost.Process: Process management in C++

Access system-API class

14

Creating Boost.Asio extensions - GitHub

What are I/O service objects, I/O services and I/O objects? How do I access ... visible in user code, I/O services do the hard ... Not all I/O services share a system ...

867KB Sizes 35 Downloads 399 Views

Recommend Documents

Notification Center Today Extensions KIM AHLBERG - GitHub
IOS 8 WIDGETS. Notification Center Today Extensions. KIM AHLBERG. We have already had some. Widgets since iOS5. Calendar,. Reminders, Weather... all ...

Creating signatures for ClamAV - GitHub
Dec 9, 2007 - 2 Debug information from libclamav .... The hash-based signatures shall not be used for text files, HTML and any other .... 10 = PDF files.

Creating custom covariate builders - GitHub
Mar 28, 2016 - A function that creates a covariateSettings object for the custom covariates. 2. ... cdmDatabaseSchema: The name of the database schema that ...

Creating a Native iOS Warehouse Application - GitHub
Dec 13, 2013 - 3. Step 3: Run the New iOS App. Tutorial: Creating a Native iOS Warehouse App ... To call this method, the app sends a message to the shared ..... Use the Xcode editor to add these stubs the same way you added the ...

Creating covariates using cohort attributes - GitHub
Mar 28, 2016 - 3.1 Creating the cohort attributes and attributes definitions . ... covariate builders that create covariates on the fly and can be re-used across ...

Creating a Modern PhoneGap Plugin - GitHub
Social Plugins: Email, X SocialSharing. Audio Plugins: DBMeter, Native Audio, Media Picker. Misc: Barcode Scanner, In App Purchase, Google Maps, Vuforia (AR), Microsoft ACE. (native controls), Tesseract (OCR, iOS). Photo by skeeze (https://pixabay.co

Extensions -
UserMenu for Panoramio Permissions Visit website ... your computer securely over the Internet. ... Create and share Google Chrome themes of your own design.

Social Extensions - Services
Social Extension increases the likelihood that annotations will show up on your ads. What are Social Extensions? How social extensions work. By default, AdWords ads that appear on Google or the. Google Display Network all have a +1 button. A web user

Extensions -
Email this page (by Google). 1.2.5 ... allows you to email the page link using your default mail client or Gmail. ... Create shapes and diagrams Permissions Visit website. Allow in incognito ... Copy and Paste HTML and text using Google's Web.

Workshop: Creating stencils with Inkscape and Potrace - GitHub
http://alternativeto.net/software/inkscape/ ... The “Fuzzy selector tool” helps a lot ... We are done with GIMP now we need to save the file in a format that potrace can ... the edges with a white brush. this way if I make a mistake i can recover

Longest common extensions in trees
Jul 9, 2015 - We start with a simple O(1) query O(n logn) space solution. For every ... store the longest common prefix between any two paths adjacent in.

HIGHER DIMENSIONAL STUDY OF EXTENSIONS ...
HIGHER DIMENSIONAL STUDY OF EXTENSIONS VIA TORSORS. 7. Corollary 0.5. Let P and G be two Picard S-2-stacks. The complex. 0→Tors(GP). D∗. 2. → Tors(GP. 2 ). D∗. 3. → Tors(GP ...... 4.1 (4), (7), (6) and (8);. (3) through the ten torsors over

Determinantal complexities and field extensions
2 Institute of Computing Technology, Chinese Academy of Sciences [email protected] ... Laboratory for Information Science and Technology, Department of Computer. Science and .... an algebraic extension of degree d to the base field increases the

16-17 YHS Extensions Directory.pdf
Page 1 of 1. YHS Extensions (7/20/2016). Adler, Stephanie 1124 Act/Ath. Aguilar, Heather 1135 I-215. Aldrich, Carrie 1142 D-2. Allen, Christa 1757 P-7. Alonzo, Jessica 1206 E-6. Anderson, Mark 1123 Athletics. Andriese, Bryan 1703 O-3. Arreola, Matthe

Online PDF Eyelash Extensions Manual
Online PDF Eyelash Extensions Manual - Professional Student Manual, Read PDF Eyelash Extensions ... qualification in applying ... book is useful for College.

Using Google AdWords product extensions, Sony increased ...
... Sony's ads on Google.com, but the. Using Google AdWords product extensions,. Sony increased conversion rates by 9 percent. Case Study | Google AdWords ...

Database Extensions Visual Walkthrough - Alberta PSUG
Oct 7, 2013 - Database extensions allow you to display customized information in ... Improve application performance when accessing database extension ...

Eyelash Extensions Bel Air.pdf
"The skin under our eyes is the thinnest skin on the human body, making it. Page 1 of 3 ... Eyelash Extensions Bel Air.pdf. Eyelash Extensions Bel Air.pdf. Open.