Build 2016 - P489 - Async Programming Improvements for C++ and UWP
-
Upload
windows-developer -
Category
Technology
-
view
911 -
download
12
Transcript of Build 2016 - P489 - Async Programming Improvements for C++ and UWP
#Build2016
Asynchronous programming with C++ UWPEric Mittelette, Program Manager (Visual C++)Gor Nishanov, Software Engineer (Visual C++)Peter Torr, Program Manager (Windows)
General Visual C++ ImprovementsMulti-device developmentCross-platform support for iOS and Android
Standard conformanceC++17 feature-complete for librariesFixed C++11 and C++14 conformance issuesClang/C2 front-end support
Performance
Code generationCompiler throughput
Better IDE supportRefactor -> Rename functionRefactor -> Extract functionImproved Intellisense for templates
Debugger improvementsVisualizationsMemory diagnosticsGraphics diagnostics
Async with WinRT
AcquireConnectionAsyncAddAndShowDeviceAccountsAsyncAddAsyncAddAudioEffectAsyncAddDatagramSocketAsyncAddDeviceAsyncAddEffectAsyncAddLicenseAsyncAddPackageAsyncAddPackageVolumeAsyncAddProfileFromObjectAsyncAddProfileFromXmlAsyncAddStreamSocketListenerAsyncAddVideoEffectAsyncAddWebAccountAsyncAppendLinesAsyncAppendTextAsyncApplyAsyncApproveSessionAsyncAttachAsyncAuthenticateAsyncAuthenticateDeviceAsyncAuthenticateSilentlyAsyncAuthenticateUserAsyncBeginServiceRequestBindEndpointAsyncBindServiceNameAsyncBufferAllAsyncBuildChainAsyncCancelAsyncCancelAsyncOperationsCancelIOAsyncCaptureAsyncCaptureFileAsyncCapturePhotoToStorageFileAsyncCapturePhotoToStreamAsyncCapturePreviewToStreamAsyncCaptureSelectedContentToDataPackageAsyncChangeAdministrativeKeyAsyncChangeAsyncChangeMessageFlagStateAsyncCheckAvailabilityAsyncCheckHealthAsyncClaimDrawerAsyncClaimPrinterAsyncClaimReaderAsyncClaimScannerAsyncCleanupPackageForUserAsyncClearAsyncClearEffectsAsyncClearPublisherCacheFolderAsyncClearRegionsAsyncClearStallAsyncClearTemporaryWebDataAsyncClearViewAsyncClearWebAccountPictureAsyncCloseAndSaveToFileAsyncCommitAsyncCompileConstraintsAsyncCompleteUpdatesAsyncConfigureAccessPointAsyncConnectAsyncConnectProfileAsyncConnectProfileWithPasswordCredentialAsyncConvertBackAsyncConvertContactToVCardAsyncConvertVCardToContactAsync
CopyAndCloseAsyncCopyAndReplaceAsyncCopyAsyncCopyFromFileAsyncCopyProtectionAsyncCopyToAsyncCreateAccountAsyncCreateAnnotationListAsyncCreateAppointmentCalendarAsyncCreateAsyncCreateContactListAsyncCreateCopyFromSurfaceAsyncCreateDashboardItemUpdaterAsyncCreateDeviceAccountAsyncCreateDeviceInputNodeAsyncCreateDeviceOutputNodeAsyncCreateDownloadAsyncCreateEndpointPairAsyncCreateEndpointPairForPortsAsyncCreateFileAsyncCreateFileForUserAsyncCreateFileInputNodeAsyncCreateFileOutputNodeAsyncCreateFolderAsyncCreateFolderForUserAsyncCreateForInPlacePropertyEncodingAsyncCreateForTranscodingAsyncCreateFromFileAsyncCreateFromHResultAsyncCreateFromIdAsyncCreateFromImageFileAsyncCreateFromStreamAsyncCreateFromUriAsyncCreateMailboxAsyncCreateMediaResourceAsyncCreateProtectedAndOpenAsyncCreatePushNotificationChannelForApplicationAsyncCreatePushNotificationChannelForSecondaryTileAsyncCreateRequestAsyncCreateResourceAsyncCreateResponseMessageAsyncCreateSocialFeedUpdaterAsyncCreateStreamedFileAsyncCreateStreamedFileFromUriAsyncCreateUploadAsyncCreateUploadFromStreamAsyncCreateWebAccountWatcherAsyncDeAuthenticateDeviceAsyncDecryptAsyncDecryptTpmAttestationCredentialAsyncDeleteAllAsyncDeleteAnnotationAsyncDeleteAppointmentAsyncDeleteAppointmentInstanceAsyncDeleteAsyncDeleteContactAsyncDeleteContainerAsyncDeleteDeviceAccountAsyncDeleteEntriesAsyncDeleteEntryAsyncDeleteImportedItemsFromSourceAsyncDeleteLicenses
DeleteMessageAsyncDeleteMessagesAsyncDeleteMultipleAsyncDeleteProfileAsyncDeleteResourceAsyncDeleteResourceItemAsyncDeleteWebAccountAsyncDenySessionAsyncDeprovisionAsyncDetectFacesAsyncDeviceInfoSupportsCastingAsyncDeviceInfoSupportsDialAsyncDisableAnnotationAsyncDisableAsyncDisconnectAsyncDisconnectProfileAsyncDownloadAttachmentAsyncDownloadMessageAsyncDropAsyncEnableAsyncEnterAsyncExecuteAsyncFilterUnsupportedSystemFeaturesAsyncFinalizeAsyncFindAccountAsyncFindAccountProviderAsyncFindAccountsAsyncFindAllAdaptersAsyncFindAllAsyncFindAllCardsAsyncFindAllForPackageAsyncFindAllInstancesAsyncFindAllPeersAsyncFindAllProviderWebAccountsAsyncFindAllSourcesAsyncFindAnnotationListsAsyncFindAnnotationsAsyncFindAnnotationsByRemoteIdAsyncFindAnnotationsForContactAsyncFindAppointmentCalendarsAsyncFindAppointmentsAsyncFindAppServiceProvidersAsyncFindChildFoldersAsyncFindConflictAsyncFindConnectionProfilesAsyncFindContactAnnotationListsAsyncFindContactIdsByEmailAsyncFindContactIdsByPhoneNumberAsyncFindContactListsAsyncFindContactsAsyncFindEmailMailboxesAsyncFindExceptionsFromMasterAsyncFindFileHandlersAsyncFindItemsAsyncFindLocalIdsFromRoamingIdAsyncFindLocalLocationsAsyncFindLocationsAsyncFindLocationsAtAsyncFindMailboxesAsyncFindMessagesAsyncFindNearbyAsyncFindRawContactsAsyncFindStartIndexAsyncFindUnexpandedAppointmentsAsyncFindUriSchemeHandlersAsyncFinishAsyncFlushAsyncFocusAsyncForwardMessageAsync
FromBluetoothAddressAsyncFromFolderAsyncFromHostNameAsyncFromIdAsyncFromNetworkAccountIdAsyncFromSmartCardAsyncGenerateSignatureAsyncGetAccountAsyncGetAnnotationAsyncGetAnnotationListAsyncGetAnswerToResetAsyncGetAppAndSupplementalPackageUpdatesAsyncGetAppAndSupplementalPackageUpdatesForUserAsyncGetApplicationLinkAsyncGetApplicationTokenBindingKeyAsyncGetApplicationTokenBindingKeyIdAsyncGetAppListEntriesAsyncGetAppointmentAsyncGetAppointmentCalendarAsyncGetAppointmentInstanceAsyncGetAppPurchaseCampaignIdAsyncGetAppReceiptAsyncGetAppStateAsyncGetAsyncGetAsyncKeyStateGetAttestationAsyncGetAttributedNetworkUsageAsyncGetAuthorityKeyContainerNameAsyncGetBasicPropertiesAsyncGetBitmapAsyncGetBlobInfoAsyncGetBrowsePolicyAsyncGetBufferAsyncGetCachedCapabilitiesAsyncGetCandidatesAsyncGetCapabilitiesAsyncGetCapabilitiesFromNetworkAsyncGetChallengeContextAsyncGetColorProfileAsyncGetConfigurationAsyncGetConnectedProfileAsyncGetConnectivityIntervalsAsyncGetContactAsyncGetContactFromRemoteIdAsyncGetContactListAsyncGetContainerInfoAsyncGetControllersAsyncGetConversationAsyncGetConversationFromThreadingInfoAsyncGetCountAsyncGetCurrentConfigurationAsyncGetCurrentDownloadsAsyncGetCurrentDownloadsForTransferGroupAsyncGetCurrentReadingAsyncGetCurrentUploadsAsyncGetCurrentUploadsForTransferGroupAsyncGetCustomerCollectionsIdAsyncGetCustomerPurchaseIdAsyncGetDataAsyncGetDataBySessionPortAsyncGetDefaultAsyncGetDefaultPrintTicketAsync
GetDeviceAccountConfigurationAsyncGetDeviceSelectorFromCastingSourceAsyncGetDisplayNameAsyncGetDocumentPropertiesAsyncGetDomainNameAsyncGetDrivingRouteAsyncGetDrivingRouteFromWaypointsAsyncGetEndpointPairsAsyncGetEntryAsyncGetExtensionPropertiesAsyncGetFeatureReportAsyncGetFileAsyncGetFileFromApplicationUriAsyncGetFileFromPathAsyncGetFilesAsyncGetFirstNameAsyncGetFolderAsyncGetFolderForUserAsyncGetFolderFromPathAsyncGetFoldersAsyncGetForUserAsyncGetFrameAsyncGetGeopositionAsyncGetGeopositionHistoryAsyncGetGeotagAsyncGetGlyphThumbnailAsyncGetHtmlFormatAsyncGetIdAsyncGetImageAsyncGetImagePropertiesAsyncGetIndexedStateAsyncGetInputReportAsyncGetInputStreamAsyncGetIsAppAllowedToInstallAsyncGetIsApplicableAsyncGetItemAsyncGetItemCountAsyncGetItemsAsyncGetLastNameAsyncGetLibraryAsyncGetLibraryForUserAsyncGetLinguisticAlternativesAsyncGetMailboxAsyncGetMeContactAsyncGetMessageAsyncGetMessageByGlobalUniqueIdAsyncGetMessageByRemoteIdAsyncGetMessageCountsAsyncGetMessagesAsyncGetMusicPropertiesAsyncGetNameAsyncGetNetworkUsageAsyncGetOneTimePassCodeAsyncGetOutputStreamAsyncGetParentAsyncGetPerUserFromPerAppAccountAsyncGetPictureAsyncGetPixelDataAsyncGetPixelsAsyncGetPreviewAsyncGetPreviewFrameAsyncGetPrimaryManagedIdentityForNetworkEndpointAsyncGetPrincipalNameAsyncGetProductReceiptAsyncGetProfilesAsyncGetPropertiesAsyncGetPropertyAsyncGetProtectionInfoAsyncGetProvisioningInfoAsyncGetProxyConfigurationAsyncGetPublicFolderAsync
GetRadiosAsyncGetRecordDetailsAsyncGetRemainingBytesInQuotaAsyncGetResourceMapAsyncGetRestrictionLevelAsyncGetRfcommServicesAsyncGetRfcommServicesForIdAsyncGetRtfAsyncGetScaledImageAsThumbnailAsyncGetSdpRawAttributesAsyncGetSessionInitiationProtocolUriAsyncGetSessionsAndUnregisteredAccountsAsyncGetSessionsAsyncGetSoftwareBitmapAsyncGetSourcesUnseenCountAsyncGetSpecialFolderAsyncGetStatisticsAsyncGetStatusAsyncGetStorageItemsAsyncGetStreamProtectionInfoAsyncGetStringAsyncGetSupportedCastingPlaybackTypesAsyncGetSupportedSymbologiesAsyncGetSyncManagerAsyncGetSyncOnDemandForUserAsyncGetSystemHistoryAsyncGetTextAsyncGetThumbnailAsyncGetThumbnailsAsyncGetTokenSilentlyAsyncGetTransportAsyncGetTransportsAsyncGetUiccAppsAsyncGetUnfulfilledConsumablesAsyncGetUnseenCountAsyncGetUriAsyncGetValueAsFileAsyncGetValueAsStreamAsyncGetVideoPropertiesAsyncGetViewsAsyncGetVoiceCallSupportAsyncGetVoiceCommandAsyncGetWalkingRouteAsyncGetWalkingRouteFromWaypointsAsyncGetWalletItemAsyncGetWebLinkAsyncGoToNextFrameAsyncImportItemAsyncImportItemsAsyncImportPfxDataAsyncIndexFileContentsAsyncInitializeAsyncInsertSlipAsyncInstallCertificateAsyncInstallCommandDefinitionsFromStorageFileAsyncInvalidateCacheAsyncInvokeScriptAsyncIsContainerAsyncIsStoreBlockedByPolicyAsyncIssueCredentialsAsyncIsSupportedAsyncIsSymbologySupportedAsyncLaunchAppForItemAsyncLaunchAsyncLaunchFileAsyncLaunchFolderAsyncLaunchFullTrustProcessForAppAsyncLaunchFullTrustProcessForCurrentAppAsync
LaunchUriAsyncLaunchUriForResultsAsyncLeaveAsyncLeaveConversationAsyncLicenseFetchAsyncLoadAddOnProductInfosAsyncLoadAsyncLoadCurrentAsyncLoadFileFromContainerAsyncLoadFromFileAsyncLoadFromStreamAsyncLoadFromUriAsyncLoadListingInformationAsyncLoadListingInformationByKeywordsAsyncLoadListingInformationByProductIdsAsyncLoadModelFromPackageAsyncLoadMoreItemsAsyncLockAsyncMakeDefaultAccountAsyncMapAllPixelsToTargetAsyncMapRegionOfPixelsToTargetAsyncMarkAllAsSeenAsyncMarkAsSeenAsyncMarkEntriesAsSeenAsyncMarkEntryAsSeenAsyncMarkFolderAsSeenAsyncMarkFolderSyncEnabledAsyncMarkMessageAsBlockedAsyncMarkMessageAsSeenAsyncMarkMessageReadAsyncMarkMessagesAsReadAsyncMarkSourcesAsSeenAsyncMeasureAsyncMergeAndValidateWithDefaultPrintTicketAsyncMoveAndReplaceAsyncMoveAppointmentAsyncMoveAsyncMovePackageToVolumeAsyncOpenAsyncOpenDrawerAsyncOpenKeyPairFromCertificateAsyncOpenReadAsyncOpenSequentialReadAsyncOpenTransactedWriteAsyncOverAsyncPairAsyncPauseAsyncPauseRecordAsyncPickAsyncPickContactAsyncPickContactsAsyncPickMultipleContactsAsyncPickMultipleFilesAsyncPickSaveFileAsyncPickSingleContactAsyncPickSingleDeviceAsyncPickSingleDialDeviceAsyncPickSingleFileAsyncPickSingleFolderAsyncPingAsyncPostAsyncPrepareAdvancedPhotoCaptureAsyncPrepareFileTranscodeAsyncPrepareForCustomAnimatedSwitchAsyncPrepareLowLagPhotoCaptureAsyncPrepareLowLagPhotoSequenceCaptureAsync
PrepareLowLagRecordToCustomSinkAsyncPrepareLowLagRecordToStorageFileAsyncPrepareLowLagRecordToStreamAsyncPrepareMediaStreamSourceTranscodeAsyncPreparePageAsyncPrepareStreamTranscodeAsyncPrepareVariablePhotoSequenceCaptureAsyncProcessEventAsyncProcessNextFrameAsyncProtectAsyncProtectStreamAsyncProvisionAsyncProvisionFromXmlDocumentAsyncPullCookiesAsyncPushCookiesAsyncPutAsyncQueryFileSupportAsyncQueryUriSupportAsyncReadAsBufferAsyncReadAsInputStreamAsyncReadAsStringAsyncReadAsyncReadBatchAsyncReadBufferAsyncReadClientCharacteristicConfigurationDescriptorAsyncReadLinesAsyncReadRecordAsyncReadTextAsyncReadValueAsyncRecognizeAsyncRecognizeWithUIAsyncRedeemTokenForFileAsyncRegisterDatagramSocketAsyncRegisterPackageAsyncRegisterPackageByFullNameAsyncRegisterStreamSocketListenerAsyncRegisterSyncManagerAsyncRegisterTransportAsyncReloadSimulatorAsyncRemoveDeviceAsyncRemoveEffectAsyncRemovePackageAsyncRemovePackageVolumeAsyncRemoveSlipAsyncRenameAsyncRenderAsyncRenderToFileAsyncRenderToStreamAsyncRenewAttestationAsyncRenewSystemComponentsAsyncRepairAsyncReplaceWithStreamedFileAsyncReplaceWithStreamedFileFromUriAsyncReportCompletedAsyncReportConsumableFulfillmentAsyncReportFailedAsyncReportFailureAsyncReportProgressAsyncReportSuccessAsyncRequestAccessAsyncRequestAccessForAppAsyncRequestAddFolderAsyncRequestAnnotationStoreAsyncRequestAppLaunchAsyncRequestAppPurchaseAsyncRequestAsyncRequestAttestedVirtualSmartCardCreationAsync
RequestConfirmationAsyncRequestContentAccessAsyncRequestCreateAsyncRequestCreateForSelectionAsyncRequestCredentialsAsyncRequestCustomPromptAsyncRequestDeleteAsyncRequestDeleteForSelectionAsyncRequestDisambiguationAsyncRequestDownloadAndInstallPackageUpdatesAsyncRequestDownloadAndInstallPackageUpdatesForUserAsyncRequestDownloadPackageUpdatesAsyncRequestDownloadPackageUpdatesForUserAsyncRequestExtensionAsyncRequestLaunchAsyncRequestPinChangeAsyncRequestPinResetAsyncRequestProductPurchaseAsyncRequestProductPurchaseByProductIdAndSkuIdAsyncRequestRemoveFolderAsyncRequestRemovePackageAsyncRequestSetAsNotificationProviderAsyncRequestSetImageFeedAsyncRequestSignAsyncRequestStartCastingAsyncRequestStartProjectingAsyncRequestStoreAsyncRequestTokenAsyncRequestUnconstrainedDownloadsAsyncRequestUnconstrainedUploadsAsyncRequestVerificationAsyncRequestVirtualSmartCardCreationAsyncRequestVirtualSmartCardDeletionAsyncReRegistrationAsyncReserveCallResourcesAsyncResetAsyncResetStatisticsAsyncResolveRecipientsAsyncResumeAsyncResumePickSingleFileAsyncResumeRecordAsyncRetainDeviceAsyncRetrieveDeviceAuthenticationDataAsyncRetrieveFeedAsyncRetrieveMediaResourceAsyncRetrievePropertiesAsyncRetrieveResourceAsyncRetrieveServiceDocumentAsyncRetrieveStatisticsAsyncRetrySendMessageAsyncRunAsyncRunIdleAsyncRunToCompletionAsyncSaveAppointmentAsyncSaveAsAsyncSaveAsyncSaveContactAsyncSaveDraftAsyncSaveEntryAsyncSaveFileAsContainerAsyncSaveMessageAsyncSaveModelToPackageAsync
SavePropertiesAsyncSaveToFileAsyncScanAsyncScanFilesToFolderAsyncScanPreviewToStreamAsyncScheduleAsyncSearchForAllUpdatesAsyncSearchForUpdatesAsyncSelectNewAsyncSelectSettingAsyncSendControlInTransferAsyncSendControlOutTransferAsyncSendFeatureReportAsyncSendIOControlAsyncSendLicenseFetchRequestAsyncSendMessageAndGetReplyAsyncSendMessageAndGetResultAsyncSendMessageAsyncSendOutputReportAsyncSendProximityDetectionResponseAsyncSendProximityDetectionStartAsyncSendQueryCommandAsyncSendRegistrationRequestAsyncSendRequestAsyncSendResponseAsyncSendResponseWithPinAsyncSendSetCommandAsyncSetAccountPictureAsyncSetAccountPictureFromStreamAsyncSetAccountPicturesAsyncSetAccountPicturesFromStreamsAsyncSetActiveProfileAsyncSetActiveSymbologiesAsyncSetAutoAsyncSetBitmapAsyncSetCategoryAsyncSetConfigurationAsyncSetEncodingPropertiesAsyncSetGeotagAsyncSetGeotagFromGeolocatorAsyncSetImageAsyncSetImageFileAsyncSetImageStreamAsyncSetLevelAsyncSetMediaStreamPropertiesAsyncSetPackageVolumeOfflineAsyncSetPackageVolumeOnlineAsyncSetPerAppToPerUserAccountAsyncSetPhraseListAsyncSetPresetAsyncSetPropertiesAsyncSetRegionsAsyncSetRelativeScrollPositionAsyncSetRemoteIdentificationInformationAsyncSetScopeAsyncSetSourceAsyncSetStateAsyncSetValueAsyncSetVersionAsyncSetViewAsyncSetWebAccountPictureAsyncShowAccountErrorResolverAsyncShowAccountSettingsAsyncShowAddAccountAsync
ShowAddAppointmentAsyncShowAppointmentDetailsAsyncShowAsStandaloneAsyncShowAsyncShowAtAsyncShowComposeNewEmailAsyncShowComposeSmsMessageAsyncShowEditNewAppointmentAsyncShowForSelectionAsyncShowPrintUIAsyncShowRemoveAppointmentAsyncShowReplaceAppointmentAsyncShowTimeFrameAsyncSignAsyncSignHashedDataAsyncSignInAsyncSignOutAsyncSignOutUserAsyncStagePackageAsyncStageUserDataAsyncStartAppInstallAsyncStartAsyncStartDragAsyncStartPreviewAsyncStartPreviewToCustomSinkAsyncStartProjectingAsyncStartRecordToCustomSinkAsyncStartRecordToStorageFileAsyncStartRecordToStreamAsyncStartSoftwareTriggerAsyncStartTetheringAsyncStopAsyncStopPreviewAsyncStopProjectingAsyncStopRecognitionAsyncStopRecordAsyncStopSoftwareTriggerAsyncStopTetheringAsyncStoreAsyncSubmitPropertySetUpdatesAsyncSubmitUpdatesAsyncSwapDisplaysForViewsAsyncSwitchAsyncSyncAsyncSynthesizeSsmlToStreamAsyncSynthesizeTextToStreamAsyncTraceOperationCompletionTranscodeAsyncTransmitAsyncTryCancelDownloadMessageAsyncTryCancelMeetingAsyncTryCancelSendMessageAsyncTryComputeLatestMeshAsyncTryCreateFolderAsyncTryCreateOrUpdateAppointmentAsyncTryDeleteFolderAsyncTryEmptyFolderAsyncTryExportAnchorsAsyncTryForwardMeetingAsyncTryGetAutoReplySettingsAsyncTryGetDepthCorrelatedCameraIntrinsicsAsyncTryGetDepthCorrelatedCoordinateMapperAsyncTryGetItemAsyncTryImportAnchorsAsyncTryLinkContactsAsync
TryMoveAsyncTryMoveFolderAsyncTryMoveMessageAsyncTryPartialRepairAsyncTryProposeNewTimeForMeetingAsyncTryReduceFacesAsyncTryRotateAsyncTryRotateToAsyncTryRunAsyncTryRunIdleAsyncTrySaveAnnotationAsyncTrySaveAsyncTrySendIOControlAsyncTrySetAutoReplySettingsAsyncTrySetLockScreenImageAsyncTrySetPreferredSourceForPictureAsyncTrySetPropertyAsyncTrySetSceneAsyncTrySetVideoProfileAsyncTrySetViewAsyncTrySetViewBoundsAsyncTrySetWallpaperImageAsyncTryShowAsStandaloneAsyncTryTiltAsyncTryTiltToAsyncTryUpdateMeetingResponseAsyncTryZoomInAsyncTryZoomOutAsyncTryZoomToAsyncUnblockAsyncUnlinkRawContactAsyncUnlockAsyncUnpairAsyncUnprojectAllPixelsAtCorrelatedDepthAsyncUnprojectRegionPixelsAtCorrelatedDepthAsyncUnprotectAsyncUnprotectStreamAsyncUpdateAppByPackageFamilyNameAsyncUpdateAsyncUpdateFirmwareAsyncUpdateKeyAsyncUpdateMediaResourceAsyncUpdatePackageAsyncUpdateProfileFromObjectAsyncUpdateProfileFromXmlAsyncUpdateResourceAsyncUpdateResourceItemAsyncUpdateSettingsAsyncUpdateStatisticsAsyncUpdateWebAccountPropertiesAsyncUpdateWnsChannelAsyncUpgradeToSslAsyncUriToStreamAsyncValidateCertificatesAsyncVerifyAsyncVerifyResponseAsyncVerifySignatureAsyncWriteAsyncWriteBufferAsyncWriteBytesAsyncWriteClientCharacteristicConfigurationDescriptorAsyncWriteDataAsyncWriteLinesAsyncWriteTextAsyncWriteToStreamAsyncWriteValueAsync
Async APIsWinRT contains over 1,300 Async APIsAny API that might stall the UI is designed to be asynchronous
Leads to more responsive applicationsApps should never appear “hung” due to disk or network latency
Consuming these APIs from C++ can be cumbersome
Demo: Opening a JPGUsing PPL tasks
Async code to open a JPGusing namespace Windows::Storage::Pickers;using namespace concurrency;
auto picker = ref new FileOpenPicker();picker->FileTypeFilter->Append(L".jpg");picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
create_task(picker->PickSingleFileAsync()).then([this](Windows::Storage::StorageFile^ file){create_task(file->OpenReadAsync()).then([this] (Windows::Storage::Streams::IRandomAccessStreamWithContentType^ stream) { auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap; });});
Async code to open a JPGusing namespace Windows::Storage::Pickers;using namespace concurrency;
auto picker = ref new FileOpenPicker();picker->FileTypeFilter->Append(L".jpg");picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
create_task(picker->PickSingleFileAsync()).then([this](Windows::Storage::StorageFile^ file){ create_task(file->OpenReadAsync()).then([this] (Windows::Storage::Streams::IRandomAccessStreamWithContentType^ stream) { auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap; });});
Async code to open a JPGusing namespace Windows::Storage::Pickers;using namespace concurrency;
auto picker = ref new FileOpenPicker();picker->FileTypeFilter->Append(L".jpg");picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
create_task(picker->PickSingleFileAsync()).then([this](Windows::Storage::StorageFile^ file){ create_task(file->OpenReadAsync()).then([this] (Windows::Storage::Streams::IRandomAccessStreamWithContentType^ stream) { auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap; });});
Async code to open a JPGusing namespace Windows::Storage::Pickers;using namespace concurrency;
auto picker = ref new FileOpenPicker();picker->FileTypeFilter->Append(L".jpg");picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
create_task(picker->PickSingleFileAsync()).then([this](Windows::Storage::StorageFile^ file){ create_task(file->OpenReadAsync()).then([this] (Windows::Storage::Streams::IRandomAccessStreamWithContentType^ stream) { auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap; });});
There’s got to be a better way!
Coroutines and co_await
Code is trivial if synchronous (open JPEG)void ShowImage(){ auto picker = ref new FileOpenPicker(); picker->FileTypeFilter->Append(L".jpg"); picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
auto file = picker->PickSingleFile(); auto stream = file->OpenRead(); auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap;}
Code is trivial if asynchronous (open JPEG)task<void> ShowImageAsync(){ auto picker = ref new FileOpenPicker(); picker->FileTypeFilter->Append(L".jpg"); picker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
auto file = co_await picker->PickSingleFileAsync(); auto stream = co_await file->OpenReadAsync(); auto bitmap = ref new BitmapImage(); bitmap->SetSource(stream); theImage->Source = bitmap;}
Demo: Opening a JPG (redux)Using co_await
More complex example: reading a socketfuture<void> do_while(function<future<bool>()> body) {
return body().then([=](future<bool> notDone) { return notDone.get() ? do_while(body) : make_ready_future(); });}
future<int> tcp_reader(int total) { struct State { char buf[4 * 1024]; int total; Tcp::Connection conn; explicit State(int total) : total(total) {} }; auto state = make_shared<State>(total); return Tcp::Connect("127.0.0.1", 1337).then( [state](future<Tcp::Connection> conn) { state->conn = std::move(conn); return do_while([state]()->future<bool> { if (state->total <= 0) return make_ready_future(false); return state->conn.read(state->buf, sizeof(state->buf)).then( [state](future<int> nBytesFut) { auto nBytes = nBytesFut.get() if (nBytes == 0) return make_ready_future(false); state->total -= nBytes; return make_ready_future(true); }); }); });}
auto tcp_reader(int total) -> future<int>{ char buf[4 * 1024]; auto conn = co_await Tcp::Connect("127.0.0.1", 1337); for (;;) { auto bytesRead = co_await conn.Read(buf, sizeof(buf)); total -= bytesRead; if (total <= 0 || bytesRead == 0) return total; }}
C++ Coroutines in depth
DART 1.9
Future<int> getPage(t) async { var c = new http.Client(); try { var r = await c.get('http://url/search?q=$t'); print(r); return r.length(); } finally { await c.close(); }}
C#
async Task<string> WaitAsynchronouslyAsync() { await Task.Delay(10000); return "Finished"; }
HACK (programming language)
async function gen1(): Awaitable<int> { $x = await Batcher::fetch(1); $y = await Batcher::fetch(2); return $x + $y; }
Python: PEP 0492 async def abinary(n): if n <= 0: return 1 l = await abinary(n - 1) r = await abinary(n - 1) return l + 1 + r
C++1z
future<string> WaitAsynchronouslyAsync() { co_await sleep_for(10ms); co_return "Finished"s; }
Coroutines are popular!
Design PrinciplesScalableto billions of concurrent coroutines
Efficientresume and suspend operations comparable in cost to a function call
Seamlessinteraction with existing facilities with no overhead
Open-endedcoroutine machinery allowing library designers to expose high-level semantics such as generators, goroutines, tasks and more
Usablein environments where exceptions are forbidden or not available
Generalized Function
User
Coroutine designer
AsyncGeneratorco_await + co_yield
Generatorco_yield
Taskco_await
Plain old function
Compiler does not care
3 x 2 x 2Three new keywordsco_await co_returnco_yield [syntactic sugar for: await $p.yield_value(expr)]
Two new conceptsAwaitableCoroutine Promise
Two library typescoroutine_handlecoroutine_traits
C++ Coroutines: Layered complexityEverybodySafe by default, novice friendlyUse coroutines and awaitables defined by standard library, boost and other high quality libraries
Power UsersDefine new awaitables to customize await for their environment using existing coroutine types
ExpertsDefine new coroutine types
Coroutines and the C++ StandardTS for C++17Latest draft: http://open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0057r2.pdf
Supported in Visual Studio 2015, Update 2“Experimental” support with /await flag until standardizedFully supported in Windows Store Apps
Clang implementation in progress
Call to ActionStart using co_await in your Universal Windows AppsRemember the /await command-line flag!
Send us your feedbackWindows: Feedback App, choose “Developer Platform” areaVC++: http://visualstudio.uservoice.com/
See more detailed talks on C++ coroutinesMeeting Cpp: https://www.youtube.com/watch?v=YYtzQ355_Co – introductory levelCppCon: https://www.youtube.com/watch?v=_fu0gx-xseY – deep-dive
See additional developer contentRe-visit //build/ on Channel 9Continue your education at Microsoft Virtual Academy online
Thanks for watching!
© 2016 Microsoft Corporation. All rights reserved.