Skip to content

Commit 7c1f7b9

Browse files
authored
Merge pull request #628 from gmlueck/gmlueck/context-constructors
Fix contradiction with context constructors
2 parents 827d0fb + 2887f9c commit 7c1f7b9

2 files changed

Lines changed: 118 additions & 27 deletions

File tree

adoc/chapters/programming_interface.adoc

Lines changed: 113 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,56 +1275,141 @@ include::{header_dir}/context.h[lines=4..-1]
12751275
[[sec:context-ctors]]
12761276
==== Constructors
12771277

1278+
All context constructors take a parameter named [code]#propList# which allows
1279+
the application to pass zero or more properties.
1280+
These properties may specify additional effects of the constructor and may also
1281+
specify exceptions that the constructor throws.
1282+
See <<sec:context-properties>> for the context properties that are defined by
1283+
the <<core-spec>>.
1284+
1285+
'''
1286+
12781287
.[apititle]#Default constructor#
12791288
[source,role=synopsis,id=api:context-ctor]
12801289
----
1281-
explicit context(async_handler asyncHandler = {})
1290+
explicit context(const property_list& propList = {})
12821291
----
12831292

1284-
_Effects:_ Constructs a [code]#context# object using the
1285-
[code]#default_selector_v# to determine the associated platform and devices.
1286-
The associated platform is the platform which contains the device selected by
1293+
_Effects:_ Constructs a [code]#context# object using the device selected by
12871294
[code]#default_selector_v#.
1288-
The <<device,devices>> that are associated with the constructed context are
1289-
implementation-defined but must contain the device that is selected by
1295+
The context's platform is the platform that contains this device.
1296+
The context contains the selected device.
1297+
The context may also contain other devices from the same platform.
1298+
Whether this happens is implementation defined.
1299+
1300+
'''
1301+
1302+
.[apititle]#Constructor with async handler#
1303+
[source,role=synopsis,id=api:context-ctor-async-handler]
1304+
----
1305+
explicit context(async_handler asyncHandler, const property_list& propList = {})
1306+
----
1307+
1308+
_Effects:_ Constructs a [code]#context# object using the device selected by
12901309
[code]#default_selector_v#.
1291-
The constructed context uses the [code]#asyncHandler# parameter to handle
1292-
exceptions.
1310+
The context's platform is the platform that contains this device.
1311+
The context contains the selected device.
1312+
The context may also contain other devices from the same platform.
1313+
Whether this happens is implementation defined.
1314+
The context has the asynchronous error handler [code]#asyncHandler#.
1315+
1316+
'''
1317+
1318+
.[apititle]#Constructor with device#
1319+
[source,role=synopsis,id=api:context-ctor-device]
1320+
----
1321+
explicit context(const device& dev, const property_list& propList = {})
1322+
----
1323+
1324+
_Effects:_ Constructs a [code]#context# object that contains the device
1325+
[code]#dev#.
1326+
The context's platform is the platform that contains [code]#dev#.
1327+
1328+
'''
1329+
1330+
.[apititle]#Constructor with device and async handler#
1331+
[source,role=synopsis,id=api:context-ctor-device-async-handler]
1332+
----
1333+
explicit context(const device& dev, async_handler asyncHandler,
1334+
const property_list& propList = {})
1335+
----
1336+
1337+
_Effects:_ Constructs a [code]#context# object that contains the device
1338+
[code]#dev#.
1339+
The context's platform is the platform that contains [code]#dev#.
1340+
The context has the asynchronous error handler [code]#asyncHandler#.
12931341

12941342
'''
12951343

1296-
.[apititle]#Construct from device#
1297-
[source,role=synopsis,id=api:context-ctor-dev]
1344+
.[apititle]#Constructor with platform#
1345+
[source,role=synopsis,id=api:context-ctor-platform]
12981346
----
1299-
explicit context(const device& dev, async_handler asyncHandler = {})
1347+
explicit context(const platform& plt, const property_list& propList = {})
13001348
----
13011349

1302-
_Effects:_ Constructs a [code]#context# object using the [code]#dev# parameter
1303-
to determine the associated platform and device.
1304-
The associated platform is the platform that contains [code]#dev#, and the
1305-
associated device is [code]#dev#.
1306-
The constructed context uses the [code]#asyncHandler# parameter to handle
1307-
exceptions.
1350+
_Effects:_ Constructs a [code]#context# object that contains all of the devices
1351+
in the platform [code]#plt#.
1352+
The context's platform is [code]#plt#.
1353+
1354+
_Throws:_ An [code]#exception# with the [code]#errc::invalid# error code if the
1355+
platform [code]#plt# contains no devices.
13081356

13091357
'''
13101358

1311-
.[apititle]#Construct from device list#
1312-
[source,role=synopsis,id=api:context-ctor-dev-list]
1359+
.[apititle]#Constructor with platform and async handler#
1360+
[source,role=synopsis,id=api:context-ctor-platform-async-handler]
13131361
----
1314-
explicit context(const std::vector<device>& deviceList,
1315-
async_handler asyncHandler = {})
1362+
explicit context(const platform& plt, async_handler asyncHandler,
1363+
const property_list& propList = {})
1364+
----
1365+
1366+
_Effects:_ Constructs a [code]#context# object that contains all of the devices
1367+
in the platform [code]#plt#.
1368+
The context's platform is [code]#plt#.
1369+
The context has the asynchronous error handler [code]#asyncHandler#.
1370+
1371+
_Throws:_ An [code]#exception# with the [code]#errc::invalid# error code if the
1372+
platform [code]#plt# contains no devices.
1373+
1374+
'''
1375+
1376+
.[apititle]#Constructor with device list#
1377+
[source,role=synopsis,id=api:context-ctor-device-list]
1378+
----
1379+
explicit context(const std::vector<device>& deviceList, const property_list& propList = {})
13161380
----
13171381

13181382
_Preconditions:_ All devices in [code]#deviceList# must be associated with the
13191383
same platform.
13201384

1321-
_Effects:_ Constructs a [code]#context# object using the [code]#deviceList#
1322-
parameter to determine the associated platform and device.
1323-
The associated platform is the platform that contains all of the devices in
1385+
_Effects:_ Constructs a [code]#context# object that contains all of the devices
1386+
in [code]#deviceList#.
1387+
The context's platform is the platform that contains the devices in
13241388
[code]#deviceList#.
1325-
The associated devices are those devices in [code]#deviceList#.
1326-
The constructed context uses the [code]#asyncHandler# parameter to handle
1327-
exceptions.
1389+
1390+
_Throws:_ An [code]#exception# with the [code]#errc::invalid# error code if
1391+
[code]#deviceList# is empty.
1392+
1393+
'''
1394+
1395+
.[apititle]#Constructor with device list and async handler#
1396+
[source,role=synopsis,id=api:context-ctor-device-list-async-handler]
1397+
----
1398+
explicit context(const std::vector<device>& deviceList, async_handler asyncHandler,
1399+
const property_list& propList = {})
1400+
----
1401+
1402+
_Preconditions:_ All devices in [code]#deviceList# must be associated with the
1403+
same platform.
1404+
1405+
_Effects:_ Constructs a [code]#context# object that contains all of the devices
1406+
in [code]#deviceList#.
1407+
The context's platform is the platform that contains the devices in
1408+
[code]#deviceList#.
1409+
The context has the asynchronous error handler [code]#asyncHandler#.
1410+
1411+
_Throws:_ An [code]#exception# with the [code]#errc::invalid# error code if
1412+
[code]#deviceList# is empty.
13281413

13291414
'''
13301415

@@ -1551,6 +1636,7 @@ At a minimum, each context must support [code]#memory_scope::work_item#,
15511636
[[sec:context-properties]]
15521637
==== Properties
15531638

1639+
The <<core-spec>> does not define any properties for the context constructors.
15541640
The [code]#property_list# constructor parameters are present for extensibility.
15551641

15561642

adoc/headers/context.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class context {
1414
explicit context(const device& dev, async_handler asyncHandler,
1515
const property_list& propList = {});
1616

17+
explicit context(const platform& plt, const property_list& propList = {});
18+
19+
explicit context(const platform& plt, async_handler asyncHandler,
20+
const property_list& propList = {});
21+
1722
explicit context(const std::vector<device>& deviceList,
1823
const property_list& propList = {});
1924

0 commit comments

Comments
 (0)